[go: nahoru, domu]

Skip to content

Commit

Permalink
Fallback to disabled cache in case template loading fails
Browse files Browse the repository at this point in the history
Fixes #13238

Signed-off-by: Michal Čihař <michal@cihar.com>
  • Loading branch information
nijel committed May 5, 2017
1 parent 92a1e5a commit e852abc
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions libraries/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,26 @@ public function render($data = array(), $helperFunctions = array())

if (file_exists($template . '.twig')) {
$this->set($data);
return $this->twig->load($this->name . '.twig')
->render($this->data);
try {
$template = $this->twig->load($this->name . '.twig');
} catch (\RuntimeException $e) {
/* Retry with disabled cache */
$this->twig->setCache(false);
$template = $this->twig->load($this->name . '.twig');
/*
* The trigger error is intentionally after second load
* to avoid triggering error when disabling cache does not
* solve it.
*/
trigger_error(
sprintf(
__('Error while working with template cache: %s'),
$e->getMessage()
),
E_USER_WARNING
);
}
return $template->render($this->data);
}

$template = $template . '.phtml';
Expand Down

0 comments on commit e852abc

Please sign in to comment.