FFFF ConsoleProfilerListener doesn't check if profile exists · Issue #60409 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

ConsoleProfilerListener doesn't check if profile exists #60409

@garak

Description

@garak

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

      1A
      0