From 70aebc8dffbb87a3c3aa0ff01254a1d3c541b2ec Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Thu, 20 Feb 2020 23:38:53 +0100 Subject: [PATCH] Throw SmartyException when setting caching attributes for cacheable plugin as compiling this would fail. Fixes #457 --- change_log.txt | 1 + libs/sysplugins/smarty_internal_method_registerplugin.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/change_log.txt b/change_log.txt index 10a0169c..ffc49d1f 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,5 @@ - fix foreachelse on arrayiterators https://github.com/smarty-php/smarty/issues/506 + - throw SmartyException when setting caching attributes for cacheable plugin https://github.com/smarty-php/smarty/issues/457 ===== 3.1.34 release ===== 05.11.2019 13.01.2020 diff --git a/libs/sysplugins/smarty_internal_method_registerplugin.php b/libs/sysplugins/smarty_internal_method_registerplugin.php index f987f6da..ed18d84b 100644 --- a/libs/sysplugins/smarty_internal_method_registerplugin.php +++ b/libs/sysplugins/smarty_internal_method_registerplugin.php @@ -48,6 +48,8 @@ class Smarty_Internal_Method_RegisterPlugin throw new SmartyException("Plugin tag '{$name}' already registered"); } elseif (!is_callable($callback)) { throw new SmartyException("Plugin '{$name}' not callable"); + } elseif ($cacheable && $cache_attr) { + throw new SmartyException("Cannot set caching attributes for plugin '{$name}' when it is cacheable."); } else { $smarty->registered_plugins[ $type ][ $name ] = array($callback, (bool)$cacheable, (array)$cache_attr); }