8000 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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
garak opened this issue May 13, 2025 · 0 comments
Open

ConsoleProfilerListener doesn't check if profile exists #60409

garak opened this issue May 13, 2025 · 0 comments

Comments

@garak
Copy link
Contributor
garak commented May 13, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
0