Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ConsoleProfilerListener doesn't check if profile exists #60409

Copy link
Copy link
Open
@garak

Description

@garak
Issue body actions

Symfony version(s) affected

7.3.0-beta2

Description

As you can see here https://github.com/symfony/symfony/blob/7.3/src/Symfony/Bundle/FrameworkBundle/EventListener/ConsoleProfilerListener.php#L146

// save profiles
foreach ($this->profiles as $r) {
    $p = $this->profiles[$r];
    $this->profiler->saveProfile($p);   // <-- no check here if $p actually exists

    // etc...
}

This causes the following exception:

[TypeError]
Symfony\Component\HttpKernel\Profiler\Profiler::saveProfile(): Argument #1 ($profile) must be of type Symfony\Component\HttpKernel\Profiler\Profile, null given, called in /my_project/
vendor/symfony/framework-bundle/EventListener/ConsoleProfilerListener.php on line 147

How to reproduce

This happens to me when calling a specific command with the --profile argument. I realize this doesn't happen with other commands, but I think anyway the missing check should be added for more consistency

Possible Solution

Replace the code above with the following:

// save profiles
foreach ($this->profiles as $r) {
    $p = $this->profiles[$r];
    if (null === $p) {
        continue;
    }
    $this->profiler->saveProfile($p);

    // etc...
}

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.