diff --git a/core/lib/Drupal/Core/Template/TwigEnvironment.php b/core/lib/Drupal/Core/Template/TwigEnvironment.php index 8118105..8828496 100644 --- a/core/lib/Drupal/Core/Template/TwigEnvironment.php +++ b/core/lib/Drupal/Core/Template/TwigEnvironment.php @@ -131,6 +131,14 @@ public function loadTemplate($name, $index = NULL) { $this->updateCompiledTemplate($cache_filename, $name); $this->storage()->load($cache_filename); } + + if (!class_exists($cls, FALSE)) { + // In some rare race conditions with concurrent requests, we might + // have failed load load the class. In that case, execute the code + // directly to make the class available. + $compiled_source = $this->compileSource($this->loader->getSource($name), $name); + eval('?' . '>' . $compiled_source); + } } }