From c23ce16cafb826c8bb4fe7aaf2a5525b29052b23 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 6 Dec 2015 20:12:05 +0100 Subject: update smarty library - seems to bring some performance improvement --- .../libs/plugins/modifier.debug_print_var.php | 26 ++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'library/Smarty/libs/plugins/modifier.debug_print_var.php') diff --git a/library/Smarty/libs/plugins/modifier.debug_print_var.php b/library/Smarty/libs/plugins/modifier.debug_print_var.php index 66363d253..e3971a046 100644 --- a/library/Smarty/libs/plugins/modifier.debug_print_var.php +++ b/library/Smarty/libs/plugins/modifier.debug_print_var.php @@ -14,26 +14,30 @@ * * @author Monte Ohrt * - * @param array|object $var variable to be formatted - * @param integer $depth maximum recursion depth if $var is an array - * @param integer $length maximum string length if $var is a string + * @param array|object $var variable to be formatted + * @param int $max maximum recursion depth if $var is an array or object + * @param int $length maximum string length if $var is a string + * @param int $depth actual recursion depth + * @param array $objects processed objects in actual depth to prevent recursive object processing * * @return string */ -function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40) +function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth = 0, $objects = array()) { $_replace = array("\n" => '\n', "\r" => '\r', "\t" => '\t' ); - switch (gettype($var)) { case 'array' : $results = 'Array (' . count($var) . ')'; + if ($depth == $max) { + break; + } foreach ($var as $curr_key => $curr_val) { $results .= '
' . str_repeat(' ', $depth * 2) . '' . strtr($curr_key, $_replace) . ' => ' - . smarty_modifier_debug_print_var($curr_val, ++$depth, $length); + . smarty_modifier_debug_print_var($curr_val, $max, $length, ++ $depth, $objects); $depth --; } break; @@ -41,10 +45,18 @@ function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40) case 'object' : $object_vars = get_object_vars($var); $results = '' . get_class($var) . ' Object (' . count($object_vars) . ')'; + if (in_array($var, $objects)) { + $results .= ' called recursive'; + break; + } + if ($depth == $max) { + break; + } + $objects[] = $var; foreach ($object_vars as $curr_key => $curr_val) { $results .= '
' . str_repeat(' ', $depth * 2) . ' ->' . strtr($curr_key, $_replace) . ' = ' - . smarty_modifier_debug_print_var($curr_val, ++$depth, $length); + . smarty_modifier_debug_print_var($curr_val, $max, $length, ++ $depth, $objects); $depth --; } break; -- cgit v1.2.3 From 26c465ad0c1d5b6801507ed190430f44ac92c672 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 6 Dec 2015 21:09:58 +0100 Subject: update smarty to 3.1.28-dev which fixes a bug where changes in a template are only visible on the second pageload which is annoying for developing --- library/Smarty/libs/plugins/modifier.debug_print_var.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'library/Smarty/libs/plugins/modifier.debug_print_var.php') diff --git a/library/Smarty/libs/plugins/modifier.debug_print_var.php b/library/Smarty/libs/plugins/modifier.debug_print_var.php index e3971a046..4ff8213ce 100644 --- a/library/Smarty/libs/plugins/modifier.debug_print_var.php +++ b/library/Smarty/libs/plugins/modifier.debug_print_var.php @@ -24,9 +24,9 @@ */ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth = 0, $objects = array()) { - $_replace = array("\n" => '\n', - "\r" => '\r', - "\t" => '\t' + $_replace = array("\n" => '\n', + "\r" => '\r', + "\t" => '\t' ); switch (gettype($var)) { case 'array' : -- cgit v1.2.3