Skip to content

Commit

Permalink
fixed dump function is_safe value when html_errors is not defined in …
Browse files Browse the repository at this point in the history
…php.ini (closes #720)
  • Loading branch information
fabpot committed May 8, 2012
1 parent 9252548 commit 078905e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/Twig/Extension/Debug.php
Expand Up @@ -18,7 +18,13 @@ class Twig_Extension_Debug extends Twig_Extension
public function getFunctions()
{
// dump is safe if var_dump is overriden by xdebug
$isDumpOutputHtmlSafe = extension_loaded('xdebug') && (false === get_cfg_var('xdebug.overload_var_dump') || get_cfg_var('xdebug.overload_var_dump')) && get_cfg_var('html_errors');
$isDumpOutputHtmlSafe = extension_loaded('xdebug')
// false means that it was not set (and the default is on) or it explicitly enabled
&& (false === ini_get('xdebug.overload_var_dump') || ini_get('xdebug.overload_var_dump'))
// false means that it was not set (and the default is on) or it explicitly enabled
// xdebug.overload_var_dump produces HTML only when html_errors is also enabled
&& (false === ini_get('html_errors') || ini_get('html_errors'))
;

return array(
'dump' => new Twig_Function_Function('twig_var_dump', array('is_safe' => $isDumpOutputHtmlSafe ? array('html') : array(), 'needs_context' => true, 'needs_environment' => true)),
Expand Down

0 comments on commit 078905e

Please sign in to comment.