Skip to content
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

Error in Symfony2's production environment (only) caused with version >= 1.4.0 #32

Closed
gnutix opened this issue Sep 3, 2013 · 15 comments · Fixed by #34
Closed

Error in Symfony2's production environment (only) caused with version >= 1.4.0 #32

gnutix opened this issue Sep 3, 2013 · 15 comments · Fixed by #34

Comments

@gnutix
Copy link

gnutix commented Sep 3, 2013

After an upgrade from 1.3.0 to 1.4.0 (or 1.4.1, tried both), the exception added in this commit f68e2a8 is thrown whenever I access one of the pages of my website (but not all of them). It happens only with app.php (not app_dev.php / app_test.php).

Here's the stacktrace :
[2013-09-03 14:59:50] request.CRITICAL: Uncaught PHP Exception LogicException: "The cache must return instances of ClassMetadata, but got false." at /var/www/xxx/vendor/jms/metadata/src/Metadata/MetadataFactory.php line 81 {"exception":"[object] (LogicException: The cache must return instances of ClassMetadata, but got false. at /var/www/xxx/vendor/jms/metadata/src/Metadata/MetadataFactory.php:81)"} []

I've reverted the library to 1.3.0 temporarily, but would very much like to see this resolved. Thanks for your help.

@schmittjoh
Copy link
Owner

Are you sure that you have not received a fatal PHP error before which was just not appearing in the Symfony logs?

@stof
Copy link
Contributor

stof commented Sep 3, 2013

@gnutix maybe you have an old 1.3 cache which would break when reading with 1.4 ? As the cache contains serialized objects, it could be possible

@gnutix
Copy link
Author

gnutix commented Sep 4, 2013

@schmittjoh I don't think there was a PHP error, as it worked fine in Symfony's dev environment (app_dev.php). I'll try to change app.php to add the debug flag.
@stof I've rm -rf app/cache/* between the updates, so it should not be an issue.

@schmittjoh
Copy link
Owner

Which cache implementation are you using?

@gnutix
Copy link
Author

gnutix commented Sep 4, 2013

Probably the default one. Here's the bundle configuration:

jms_di_extra:
    disable_grep: %disable_grep_usage%
    locations:
        all_bundles: false
        bundles: [MyBundle, AnotherBundle]
        directories: [%kernel.root_dir%/../src]

@schmittjoh
Copy link
Owner

Can you gist the contents of the cache files?

@gnutix
Copy link
Author

gnutix commented Sep 4, 2013

I'll try to do that tonight, kind of busy at work right now.

@tommygnr
Copy link
Contributor

I am also being bitten by this since upgrading to 1.4. I am also running a symfony2 app. Where should I be looking for the cache files?

@schmittjoh
Copy link
Owner

If you have not changed it app/cache/prod/jms_diextra/metadata.

@gnutix
Copy link
Author

gnutix commented Sep 10, 2013

Hi @schmittjoh. I've finally found some time to take a deeper look into this issue. Seems like a filesystem rights one, for what I can tell. Here's the gist you've asked for: https://gist.github.com/gnutix/0ec997f80daa974af414

First, I started with 1.3.0, cleared the cache in prod, loaded my page in SF2 prod env, working fine (didn't thought to check the filesystem rights at this time, sorry).

Then, I updated to 1.4.1, cleared the cache in prod, loaded my page in SF2 prod env, and found the "buggy" result (see gist) with the Permission denied PHP warning and the above mentionned exception in Symfony2's prod.log.

So I checked the filesystem rights for the cache file and here it was : -rw-------+.
I've executed the following script :

#!/bin/sh
sudo setfacl -R -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs
sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs

And the file rights have been changed to -rw-rwx---+, which has solved the issue altogether.
@tommygnr Hope this will help you.

@tommygnr
Copy link
Contributor

@gnutix Yeah this seems to be the problem for me too. Good work.

@schmittjoh
Copy link
Owner

So, this is a permission issue on your machine if I understand correctly?

On Wed, Sep 11, 2013 at 3:22 AM, Tom Corrigan [email protected]:

@gnutix https://github.com/gnutix Yeah this seems to be the problem for
me too. Good work.


Reply to this email directly or view it on GitHubhttps://github.com//issues/32#issuecomment-24207069
.

@gnutix
Copy link
Author

gnutix commented Sep 11, 2013

@schmittjoh Yup, seems like it.

@gnutix gnutix closed this as completed Sep 11, 2013
@tommygnr
Copy link
Contributor

This is not actually a machine specific error. The changes made in this commit result in the file being created with very restrictive permissions 600

This caught me out because I schedule some symfony commands with cron. These are executed by a different user that is unable to read the file. Hence the exception is thrown. I will work on a PR to fix this, it should simply be a matter of chmoding the file after creation.

tommygnr added a commit to tommygnr/metadata that referenced this issue Sep 13, 2013
@gnutix
Copy link
Author

gnutix commented Sep 13, 2013

Nice catch! Indeed once in production I had issues again, and your change fix it. @schmittjoh Could you please merge his commit and tag a new release asap ? Thanks.

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 a pull request may close this issue.

4 participants