When you are clearing caches while a site is being visited, then you sometimes get fatal errors like this:
Class '__TwigTemplate_e420be0e76e7b05d16c9c1bd35cee0103be31106e96972ab01f86f0a60b76811' not found
Happens in core/lib/Drupal/Core/Template/TwigEnvironment.php:141
I'm not quite sure why this happens. Was writing a few theories, but every time I look into them closer, I find out something new.
So it seems to be able to load the file, but then the class isn't found. Maybe the file is still being written? but then the file system should protect us from that?
It sometimes only happens once, the second request is then fine. But I have a few of those fatal errors in our logs. This error is also reproducible in some cluster/shared filesystem circumstances, like when running drupal with a shared files directory with slow disk access, or after initial install or cache clears in certain circumstances.
- Remove the exists method. It's broken.
- Augment load with a success callback. This way it can check whether the loading resulted in what the caller asked for and retry if not. Possible use cases: loading classes, functions, variables.
- Add a loadClass method wrapping load as this is the most common case.
RTBC the patch (which has a lot of manual testing at this point, but is decidedly tricky to write automated tests for).
User interface changes
Beta phase evaluation
|Issue category||Bug because fatal errors can cause sites to be unreachable until manual cache clear is performed|
|Issue priority||Critical because its easy to replicate error situation|
|Prioritized changes||Bug fixes are prioritized changes in the beta phase/td>|
|Disruption||The change is not disruptive|
PASSED: [[SimpleTest]]: [PHP 5.5 MySQL] 99,843 pass(es). View
PASSED: [[SimpleTest]]: [PHP 5.5 MySQL] 99,014 pass(es). View
PASSED: [[SimpleTest]]: [PHP 5.5 MySQL] 98,274 pass(es). View
PASSED: [[SimpleTest]]: [PHP 5.5 MySQL] 98,120 pass(es). View