Skip to content

Instantly share code, notes, and snippets.

@lkacenja
Created September 17, 2015 16:17
Show Gist options
  • Save lkacenja/2dc7efc08073a59b7902 to your computer and use it in GitHub Desktop.
Save lkacenja/2dc7efc08073a59b7902 to your computer and use it in GitHub Desktop.
function twig_shutdown() {
$is_error = false;
if ($error = error_get_last()){
switch($error['type']){
case E_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_USER_ERROR:
case E_PARSE:
$is_error = TRUE;
break;
}
}
if ($is_error) {
watchdog('twig', 'A fatal error occured. Clearing Twig caches now. ' . time());
twig_clear_cache();
drupal_goto($_GET['q']);
}
}
register_shutdown_function('twig_shutdown');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment