From 4f89f6d84fdcb3c1859f9e11adeb820fd06dbb78 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Mon, 13 Apr 2020 22:26:24 +0200 Subject: [PATCH] Throw SmartyException when setting caching attributes for cacheable plugin as compiling this would fail (#573) 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 082b36fb3..946e99bd4 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 - fix errors that occured where isset was replaced with null check such as https://github.com/smarty-php/smarty/issues/453 ===== 3.1.34 release ===== 05.11.2019 diff --git a/libs/sysplugins/smarty_internal_method_registerplugin.php b/libs/sysplugins/smarty_internal_method_registerplugin.php index f987f6da5..ed18d84bb 100644 --- a/libs/sysplugins/smarty_internal_method_registerplugin.php +++ b/libs/sysplugins/smarty_internal_method_registerplugin.php @@ -48,6 +48,8 @@ public function 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); }