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 --- .../Smarty/libs/plugins/modifier.date_format.php | 2 +- .../libs/plugins/modifier.debug_print_var.php | 26 ++++++++++++++++------ .../libs/plugins/outputfilter.trimwhitespace.php | 4 ++-- 3 files changed, 22 insertions(+), 10 deletions(-) (limited to 'library/Smarty/libs/plugins') diff --git a/library/Smarty/libs/plugins/modifier.date_format.php b/library/Smarty/libs/plugins/modifier.date_format.php index 5ad7540b1..28d6ff021 100644 --- a/library/Smarty/libs/plugins/modifier.date_format.php +++ b/library/Smarty/libs/plugins/modifier.date_format.php @@ -33,7 +33,7 @@ function smarty_modifier_date_format($string, $format = null, $default_date = '' $format = Smarty::$_DATE_FORMAT; } /** - * Include the {@link shared.make_timestamp.php} plugin + * require_once the {@link shared.make_timestamp.php} plugin */ require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'); if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') { 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; diff --git a/library/Smarty/libs/plugins/outputfilter.trimwhitespace.php b/library/Smarty/libs/plugins/outputfilter.trimwhitespace.php index 62ab4e776..ad35d11a2 100644 --- a/library/Smarty/libs/plugins/outputfilter.trimwhitespace.php +++ b/library/Smarty/libs/plugins/outputfilter.trimwhitespace.php @@ -45,7 +45,7 @@ function smarty_outputfilter_trimwhitespace($source) // capture html elements not to be messed with $_offset = 0; - if (preg_match_all('#<(script|pre|textarea)[^>]*>.*?#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { + if (preg_match_all('#(]*>.*?]*>)|(]*>.*?]*>)|(]*>.*?]*>)#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { foreach ($matches as $match) { $store[] = $match[0][0]; $_length = strlen($match[0][0]); @@ -62,7 +62,7 @@ function smarty_outputfilter_trimwhitespace($source) // can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements '#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2', // remove spaces between attributes (but not in attribute values!) - '#(([a-z0-9]\s*=\s*(["\'])[^\3]*?\3)|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \4', + '#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5', // note: for some very weird reason trim() seems to remove spaces inside attributes. // maybe a \0 byte or something is interfering? '#^\s+<#Ss' => '<', -- cgit v1.2.3