diff --git a/libs/plugins/function.html_select_date.php b/libs/plugins/function.html_select_date.php index 763fc60f..1fec0110 100644 --- a/libs/plugins/function.html_select_date.php +++ b/libs/plugins/function.html_select_date.php @@ -306,11 +306,36 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem $_html_months .= '' . $option_separator; } + + $formatter = null; + $format_compare = '%m'; + if (class_exists('IntlDateFormatter')) { + $format_compare = 'm'; + $patterns = array('%b', '%h', '%B', '%m'); + $replacement = array('MMM', 'MMM', 'MMMM', 'MM'); + $month_format = str_replace($patterns, $replacement, $month_format); + $month_value_format = str_replace($patterns, $replacement, $month_value_format); + $formatter = new IntlDateFormatter( + setlocale(LC_TIME, '0'), + IntlDateFormatter::NONE, + IntlDateFormatter::NONE) + ; + } for ($i = 1; $i <= 12; $i++) { + if (null !== $formatter) { + $formatter->setPattern($month_format); + $_text = $formatter->format($_month_timestamps[ $i ]); + $formatter->setPattern($month_value_format); + $_value = $formatter->format($_month_timestamps[ $i ]); + } else { + $_text = strftime($month_format, $_month_timestamps[ $i ]); + $_value = strftime($month_value_format, $_month_timestamps[ $i ]); + } + $_val = sprintf('%02d', $i); $_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[ $i ]) : - ($month_format === '%m' ? $_val : strftime($month_format, $_month_timestamps[ $i ])); - $_value = $month_value_format === '%m' ? $_val : strftime($month_value_format, $_month_timestamps[ $i ]); + ($month_format === $format_compare ? $_val : $_text); + $_value = $month_value_format === $format_compare ? $_val : $_value; $_html_months .= '' . $option_separator; } diff --git a/libs/sysplugins/smarty_internal_cacheresource_file.php b/libs/sysplugins/smarty_internal_cacheresource_file.php index abed98d8..c77ae9e1 100644 --- a/libs/sysplugins/smarty_internal_cacheresource_file.php +++ b/libs/sysplugins/smarty_internal_cacheresource_file.php @@ -196,8 +196,8 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource */ public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached) { - clearstatcache(true, $cached->lock_id); - if (is_file($cached->lock_id)) { + clearstatcache(true, $cached->lock_id ?? ''); + if (null !== $cached->lock_id && is_file($cached->lock_id)) { $t = filemtime($cached->lock_id); return $t && (time() - $t < $smarty->locking_timeout); } else { diff --git a/libs/sysplugins/smarty_internal_compile_function.php b/libs/sysplugins/smarty_internal_compile_function.php index d0f2b0f4..84e9584d 100644 --- a/libs/sysplugins/smarty_internal_compile_function.php +++ b/libs/sysplugins/smarty_internal_compile_function.php @@ -157,7 +157,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase $output = "template->compiled->nocache_hash}%%*/smarty->ext->_tplFunction->restoreTemplateVariables(\\\$_smarty_tpl, '{$_name}');?>\n"; $output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\";\n?>"; - $output .= "template->compiled->nocache_hash}', \$_smarty_tpl->compiled->nocache_hash, ob_get_clean());\n"; + $output .= "template->compiled->nocache_hash}', \$_smarty_tpl->compiled->nocache_hash ?? '', ob_get_clean());\n"; $output .= "}\n}\n"; $output .= "/*/ {$_funcName}_nocache */\n\n"; $output .= "?>\n"; diff --git a/libs/sysplugins/smarty_internal_config_file_compiler.php b/libs/sysplugins/smarty_internal_config_file_compiler.php index 90c5dcef..a9b940e5 100644 --- a/libs/sysplugins/smarty_internal_config_file_compiler.php +++ b/libs/sysplugins/smarty_internal_config_file_compiler.php @@ -158,7 +158,7 @@ class Smarty_Internal_Config_File_Compiler } // template header code $template_header = - "template->source->filepath}' */ ?>\n"; $code = 'smarty->ext->configLoad->_loadConfigVars($_smarty_tpl, ' . diff --git a/libs/sysplugins/smarty_internal_runtime_codeframe.php b/libs/sysplugins/smarty_internal_runtime_codeframe.php index 983ca618..b5361c9b 100644 --- a/libs/sysplugins/smarty_internal_runtime_codeframe.php +++ b/libs/sysplugins/smarty_internal_runtime_codeframe.php @@ -45,7 +45,7 @@ class Smarty_Internal_Runtime_CodeFrame $properties[ 'cache_lifetime' ] = $_template->cache_lifetime; } $output = "source->filepath) . "' */\n\n"; $output .= "/* @var Smarty_Internal_Template \$_smarty_tpl */\n"; $dec = "\$_smarty_tpl->_decodeProperties(\$_smarty_tpl, " . var_export($properties, true) . ',' . diff --git a/libs/sysplugins/smarty_internal_templatecompilerbase.php b/libs/sysplugins/smarty_internal_templatecompilerbase.php index 6a8dc9c4..27261614 100644 --- a/libs/sysplugins/smarty_internal_templatecompilerbase.php +++ b/libs/sysplugins/smarty_internal_templatecompilerbase.php @@ -1135,7 +1135,7 @@ abstract class Smarty_Internal_TemplateCompilerBase flush(); } $e = new SmartyCompilerException($error_text); - $e->line = $line; + $e->setLine($line); $e->source = trim(preg_replace('![\t\r\n]+!', ' ', $match[ $line - 1 ])); $e->desc = $args; $e->template = $this->template->source->filepath; diff --git a/libs/sysplugins/smartycompilerexception.php b/libs/sysplugins/smartycompilerexception.php index f7ad39b9..8833aa52 100644 --- a/libs/sysplugins/smartycompilerexception.php +++ b/libs/sysplugins/smartycompilerexception.php @@ -16,12 +16,12 @@ class SmartyCompilerException extends SmartyException } /** - * The line number of the template error - * - * @type int|null + * @param int $line */ - public $line = null; - + public function setLine($line) + { + $this->line = $line; + } /** * The template source snippet relating to the error * diff --git a/tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php b/tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php index 92207d2a..dc4c1cd7 100644 --- a/tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php +++ b/tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php @@ -30,7 +30,8 @@ class CacheResourceTestCommon extends PHPUnit_Smarty public function compiledPrefilter($text, Smarty_Internal_Template $tpl) { - return str_replace('#', $tpl->getTemplateVars('test'), $text); + $replace = $tpl->getTemplateVars('test'); + return str_replace('#', $replace ?? '', $text); } /** diff --git a/tests/UnitTests/ResourceTests/Stream/StreamResourceTest.php b/tests/UnitTests/ResourceTests/Stream/StreamResourceTest.php index 6d0201bd..402f0226 100644 --- a/tests/UnitTests/ResourceTests/Stream/StreamResourceTest.php +++ b/tests/UnitTests/ResourceTests/Stream/StreamResourceTest.php @@ -234,7 +234,7 @@ class ResourceStream $v = &$GLOBALS[$this->varname]; $l = strlen($data); $p = &$this->position; - $v = substr($v, 0, $p) . $data . substr($v, $p += $l); + $v = substr($v ?? '', 0, $p) . $data . substr($v ?? '', $p += $l); return $l; } diff --git a/tests/UnitTests/SecurityTests/SecurityTest.php b/tests/UnitTests/SecurityTests/SecurityTest.php index 72bb3cdc..1ffcc984 100644 --- a/tests/UnitTests/SecurityTests/SecurityTest.php +++ b/tests/UnitTests/SecurityTests/SecurityTest.php @@ -394,7 +394,7 @@ class ResourceStreamSecurity $v = &$GLOBALS[$this->varname]; $l = strlen($data); $p = &$this->position; - $v = substr($v, 0, $p) . $data . substr($v, $p += $l); + $v = substr($v ?? '', 0, $p) . $data . substr($v ?? '', $p += $l); return $l; } diff --git a/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/StreamVariableTest.php b/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/StreamVariableTest.php index e49d6205..18560ba8 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/StreamVariableTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/StreamVariableTest.php @@ -96,7 +96,7 @@ class VariableStream $v = &$GLOBALS[$this->varname]; $l = strlen($data); $p = &$this->position; - $v = substr($v, 0, $p) . $data . substr($v, $p += $l); + $v = substr($v ?? '', 0, $p) . $data . substr($v ?? '', $p += $l); return $l; }