8000 [Command] Cache:clear is broken · Issue #7604 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Command] Cache:clear is broken #7604

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

Closed
XWB opened this issue Apr 8, 2013 · 7 comments
Closed

[Command] Cache:clear is broken #7604

XWB opened this issue Apr 8, 2013 · 7 comments

Comments

@XWB
Copy link
Contributor
XWB commented Apr 8, 2013

We have a custom AppKernel:

use Symfony\Component\HttpKernel\Kernel;

class AppKernel extends Kernel
{
    protected $data;

    public function __construct($environment, $debug, array $data)
    {
        parent::__construct($environment, $debug);

        $this->data = $data;
    }
}

$kernel = new AppKernel('dev', true, [1, 2, 4]);

Running the cache:clear command throws the following exception:

Catchable Fatal Error: Argument 3 passed to AppKernel::__construct() must be of the type array, none given, called in CacheClearCommand.php on line 198 and defined in /path/AppKernel.php line 15

Now let's have a look in CacheClearCommand.php on line 198: https://github.com/symfony/symfony/blob/2.2/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php#L198

return new $class($parent->getEnvironment(), $parent->isDebug());

Adding a third parameter makes the command working again:

return new $class($parent->getEnvironment(), $parent->isDebug(), [1, 2, 4]);

I believe the command is broken since Symfony 2.2.1. How should this be fixed?

@mweimerskirch
Copy link
Contributor

You added the "$data" argument yourself and made it required.
It is not present in the original constructor: https://github.com/symfony/symfony/blob/2.2/src/Symfony/Component/HttpKernel/Kernel.php#L80

You should just make it optional ($data = null in the method signature)...

@XWB
Copy link
Contributor Author
XWB commented Apr 8, 2013

We are loading some config files based on stuff in $data, setting it to null is not really an option. This always worked in previous Symfony versions and nothing is mentioned in the 2.2 changelog so I'm wondering why that is.

@tiraeth
Copy link
tiraeth commented Apr 8, 2013

Overload the application (Console\Application) and put the data you want to have. It's the only option I believe and doing this shouldn't be a big deal.

@vicb
Copy link
Contributor
vicb commented Apr 9, 2013

Could you try reverting #7360 to see if it helps ?

@XWB
Copy link
Contributor Author
XWB commented Apr 9, 2013

I reverted the 3 commits from #7360 but I'm still getting the same error. Then it's probably an undocumented s2.2 feature/bc break I guess.

@jfsimon
Copy link
Contributor
jfsimon commented Apr 11, 2013

The cache:clear command boots a temporary kernel: https://github.com/symfony/symfony/blob/2.2/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php#L198

Does your $data parameter vary from a front controller to another? Isn't it possible to put these data in DIC parameters (varying with your environment)?

Anyway, how could the command determine which data to pass to this argument? I don't think your problem is fixable. You can replace this command with your own class extending existing one and override the getTempKernel method.

@ghost
Copy link
ghost commented Apr 11, 2013

jfsimon, well it did used to work.I was using a similiar technique myself

@XWB XWB closed this as completed Jun 5, 2013
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

5 participants
0