Discussion:
ReflectionException in cache:clear
Olivier Scherler
2012-02-16 18:12:51 UTC
Permalink
Hello everybody,

I had a weird problem that I finally solved, but I’m having a hard time
understanding what happened.

I was deploying my project on a new server, and everything was going
smoothly, until I switched to the prod environment. Some actions were
working, other weren’t. I cleared the cache several times and looked at
prod.log. It didn’t exist. No a permissions problem. The problematic
actions were also giving no output whatsoever in the browser.

It was finally when I cleared the prod cache with --no-debug (no idea what
it does) that I got the following error:

[ReflectionException]
Class My\GreatBundle\Entity\Foo does not exist

Indeed, I had in my model a couple references, in Doctrine generator
comments (I use yml) and type hinting, to that class that doesn’t exist
anymore because I moved it. The methods with these references are not used
in these action. I replaced them with the new class and everything is now
fixed.

Any ideas of what happened? That is:

- why does it only happen in prod mode?
- why does it only give the error with --no-debug?
- what does --no-debug do?
- why does it prevent even the prod log from being written?

Cheers,
Olivier
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Matt Foster
2012-02-17 02:20:25 UTC
Permalink
Hey Oliver,

So if you take a look at Symfony\Bundle\FrameworkBundle\Command
\CacheClearCommand you'll find all your answers. Being curious about
it I looked into a bit and the short of it is --no-warmup simply
deletes the directory and waits for the next request or console
command to rebuild it, and with "the warmer" it will rebuild the cache
directory for you, at least the service container and the classes.php
file etc.

The development environment will regenerate it's cache must more
frequently than production so that isn't surprising. Also if the
error is occurring before the Monolog service is on it's feet there is
no way to write to the log, you should also be checking your php error
log as well.

Cheers,
Matt
Post by Olivier Scherler
Hello everybody,
I had a weird problem that I finally solved, but I’m having a hard time
understanding what happened.
I was deploying my project on a new server, and everything was going
smoothly, until I switched to the prod environment. Some actions were
working, other weren’t. I cleared the cache several times and looked at
prod.log. It didn’t exist. No a permissions problem. The problematic
actions were also giving no output whatsoever in the browser.
It was finally when I cleared the prod cache with --no-debug (no idea what
  [ReflectionException]
  Class My\GreatBundle\Entity\Foo does not exist
Indeed, I had in my model a couple references, in Doctrine generator
comments (I use yml) and type hinting, to that class that doesn’t exist
anymore because I moved it. The methods with these references are not used
in these action. I replaced them with the new class and everything is now
fixed.
- why does it only happen in prod mode?
- why does it only give the error with --no-debug?
- what does --no-debug do?
- why does it prevent even the prod log from being written?
Cheers,
Olivier
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Olivier Scherler
2012-02-17 09:37:00 UTC
Permalink
Post by Matt Foster
So if you take a look at Symfony\Bundle\FrameworkBundle\Command
\CacheClearCommand you'll find all your answers.  Being curious about
it I looked into a bit and the short of it is --no-warmup simply
deletes the directory and waits for the next request or console
command to rebuild it, and with "the warmer" it will rebuild the cache
directory for you, at least the service container and the classes.php
file etc.
I was talking about --no-debug, that’s given in the inline help
(should be deleted), but looking at the source, it does nothing.

In practice, it gave me that ReflectionException, that I didn’t get
without --no-debug. Unless that exception is intermittent and it was a
coincidence.
Post by Matt Foster
The development environment will regenerate it's cache must more frequently than production so that isn't surprising.
Sorry but I didn’t get this. Cache clearing should not be affected by
how many times you clear it. So if I cleared it once (as if only once
;)) just now for the prod environment, it should be enough. The fact
that the dev environment regenerates its cache more often should have
no incidence on the problem.
Post by Matt Foster
Also if the error is occurring before the Monolog service is on it's feet there is no way to write to the log, you should also be checking your php error log as well.
Well, in dev, the error is not even showing up. Everything works
without a hitch. And the prod cache was cleared so it’s not a cache
problem. And my PHP error log is all but empty.

So what I’d like to know is: how can an error affect Symfony so much
in the prod environment that it doesn’t even reach the point where it
loads Monolog, but cause no problem in the dev environment whatsoever,
not even a warning or a log entry; and what can I do to identify the
source of such problems, if I get no feedback about it?

Can it be a sanity check (the name ReflectionException suggests it)
that’s only run in prod (as I said the offending code is not (yet)
called in my project)? If so, shouldn’t it generate a warning in dev?
Or would there be a way to make such a check from the command line?

Cheers,
Olivier
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Ezequiel Rabinovich
2012-02-17 12:37:35 UTC
Permalink
Hey, --no-debug is what prevents the log from being written (that's what it's for).

Also, production has a much more aggressive caching. It seems to cache the entities, so when it warmed up the cache, it would have thrown that error even if dev would only throw it if the entity was accessed.

I think it was just a coincidence the --no-debug and the fact that the error was shown, I can't think of any way the two might be related.

Cheers

--
Ezequiel Rabinovich
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
Post by Matt Foster
So if you take a look at Symfony\Bundle\FrameworkBundle\Command
\CacheClearCommand you'll find all your answers. Being curious about
it I looked into a bit and the short of it is --no-warmup simply
deletes the directory and waits for the next request or console
command to rebuild it, and with "the warmer" it will rebuild the cache
directory for you, at least the service container and the classes.php
file etc.
I was talking about --no-debug, that’s given in the inline help
(should be deleted), but looking at the source, it does nothing.
In practice, it gave me that ReflectionException, that I didn’t get
without --no-debug. Unless that exception is intermittent and it was a
coincidence.
Post by Matt Foster
The development environment will regenerate it's cache must more frequently than production so that isn't surprising.
Sorry but I didn’t get this. Cache clearing should not be affected by
how many times you clear it. So if I cleared it once (as if only once
;)) just now for the prod environment, it should be enough. The fact
that the dev environment regenerates its cache more often should have
no incidence on the problem.
Post by Matt Foster
Also if the error is occurring before the Monolog service is on it's feet there is no way to write to the log, you should also be checking your php error log as well.
Well, in dev, the error is not even showing up. Everything works
without a hitch. And the prod cache was cleared so it’s not a cache
problem. And my PHP error log is all but empty.
So what I’d like to know is: how can an error affect Symfony so much
in the prod environment that it doesn’t even reach the point where it
loads Monolog, but cause no problem in the dev environment whatsoever,
not even a warning or a log entry; and what can I do to identify the
source of such problems, if I get no feedback about it?
Can it be a sanity check (the name ReflectionException suggests it)
that’s only run in prod (as I said the offending code is not (yet)
called in my project)? If so, shouldn’t it generate a warning in dev?
Or would there be a way to make such a check from the command line?
Cheers,
Olivier
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com (http://symfony-project.com)
You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Olivier Scherler
2012-02-17 13:21:22 UTC
Permalink
OK, it’s starting to make sense. I’ll make some more tests when I have
time. Thanks.
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Ezequiel Rabinovich
2012-02-17 13:26:24 UTC
Permalink
No problem, let us know how the tests worked.

Cheers

Ezequiel Rabinovich.

Sent from my iPhone
Post by Olivier Scherler
OK, it’s starting to make sense. I’ll make some more tests when I have
time. Thanks.
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Loading...