This came up while working on.
When twig_render_template() catches a \Twig_Error_Loader exception (for example when a Twig template is not found), the $output variable and its array keys are not yet defined, but twig_render_template() carries on trying to manipulate them and you get some excessive notices:
Notice: Undefined variable: output in twig_render_template() (line 66 of core/themes/engines/twig/twig.engine). Notice: Undefined index: debug_prefix in twig_render_template() (line 66 of core/themes/engines/twig/twig.engine). Notice: Undefined index: debug_info in twig_render_template() (line 101 of core/themes/engines/twig/twig.engine). Notice: Undefined index: debug_suffix in twig_render_template() (line 104 of core/themes/engines/twig/twig.engine).
These notices don't affect functionality at all, but they are annoying.
Minor internal refactor: Initialize $output and its array keys early so that only the actual \Twig_Error_Loader exception (via
drupal_set_message()) is shown.
Patch Tests (no test additions/changes made, see #4)
Beta phase evaluation
|Issue category||Bug because the patch fixes PHP notices.|
|Issue priority||Normal, just a bug fix for annoying PHP notices when Twig templates are not found.|
|Prioritized changes||Bug fix|
|Disruption||Not disruptive at all, minor internal refactor to remove PHP notices.|
User interface changes
Gets rid of ugly notices when, for example, a Twig template is not found.