From 2c7a9e172c1b3f941f2f4fa76aff97ea0d93f770 Mon Sep 17 00:00:00 2001 From: shadowwa Date: Sun, 16 Mar 2025 15:46:47 +0100 Subject: [PATCH] using php function time in template should display a warning Fixes #1114 --- libs/sysplugins/smarty_internal_templatecompilerbase.php | 2 +- .../TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/sysplugins/smarty_internal_templatecompilerbase.php b/libs/sysplugins/smarty_internal_templatecompilerbase.php index 4635e1411..8c2ac4957 100644 --- a/libs/sysplugins/smarty_internal_templatecompilerbase.php +++ b/libs/sysplugins/smarty_internal_templatecompilerbase.php @@ -659,7 +659,7 @@ public function compilePHPFunctionCall($name, $parameter) if ( !$this->smarty->loadPlugin('smarty_modifiercompiler_' . $name) && !isset($this->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$name]) - && !in_array($name, ['time', 'join', 'is_array', 'in_array', 'count']) + && !in_array($name, ['join', 'is_array', 'in_array', 'count']) ) { trigger_error('Using unregistered function "' . $name . '" in a template is deprecated and will be ' . 'removed in a future release. Use Smarty::registerPlugin to explicitly register ' . diff --git a/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php b/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php index 2c0ee95c8..b07898542 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php @@ -291,7 +291,7 @@ public function dataDeprecationNoticesForSmarty5() ['{$f|number_format:1:","}', "3,1", false], ['{if in_array(1, $ar)}yes{/if}', "yes", false], ['{if is_array($ar)}yes{/if}', "yes", false], - ['{if time() gt 0}yes{/if}', "yes", false], + ['{if time() gt 0}yes{/if}', "yes", true], ['{if array_chunk($ar, 2)}x{else}y{/if}', '', true], ['{$a|addslashes}', '', true],