Skip to content

[HttpKernel] fixed kernel re-init (when getting unserialized for eg.) #6326

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
wants to merge 1 commit into from
Closed

[HttpKernel] fixed kernel re-init (when getting unserialized for eg.) #6326

wants to merge 1 commit into from

Conversation

bamarni
Copy link
Contributor

@bamarni bamarni commented Dec 13, 2012

fixes #6254

This was happening to me because in app/cache/dev/appDevUrlMatcher.php.meta I have a Symfony\Component\HttpKernel\Config\FileLocator serialized object, at some point a ConfigCache needs to unserialize this file, when it does, a Kernel gets unserialized too (because this FileLocator class depends on it), and it leads to re-initializing the kernel.

When a kernel object gets unserialized, it's being constructed, then
initialized, there shouldn't be any need to call the init method
twice in a process, it basically only contains static calls
affecting some PHP ini settings or error handlers, actually it can lead
to unexpected things if it's called more than once, for eg. having
duplicate error messages or registering DebugClassLoaders for
DebugClassLoaders.

Imo this method shouldn't even be publicly accessible, but I didn't
wanted to break things.
@fabpot
Copy link
Member

fabpot commented Dec 13, 2012

I'd rather fix the root cause because IIUC, in your case, you then have 2 kernels.

@bamarni
Copy link
Contributor Author

bamarni commented Dec 13, 2012

Yes but I don't think this is specific to me, I can see the kernel has been designed to support serialization (it implements Serializable), so the same issue will likely occur anytime the kernel or a class depending on the kernel gets unserialized.

It looks related to some Symfony internals, here is the class causing me this issue : https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/Config/FileLocator.php This class depends on the Kernel, and an instance of it is being serialized in app/cache/dev/appDevUrlMatcher.php.meta.

If nobody can reproduce this I'll try to push something on github.

@bamarni
Copy link
Contributor Author

bamarni commented Dec 15, 2012

I'm getting this error with a fresh standard edition (latest and deps updated to their latest too) if I only remove the semi-colon at the end of this line for eg : https://github.com/symfony/symfony-standard/blob/master/src/Acme/DemoBundle/Controller/DemoController.php#L30 and request the /demo/hello/world path. It seems strange to me that you don't have it.

@bamarni bamarni closed this Dec 15, 2012
@mpdude
Copy link
Contributor

mpdude commented Apr 12, 2013

@bamarni #7230 might provide a solution. Do you still experience the issue and can you tell me which class in the .meta file is it that holds the FileLocator reference?

@bamarni
Copy link
Contributor Author

bamarni commented Apr 12, 2013

@mpdude : this "init()" method has been deprecated, so it's fixed now.

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

Successfully merging this pull request may close these issues.

2 issues with new fatal error displaying
3 participants