From a5961606f3bb76d0fe8b68da8c106f3a40cbd876 Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Fri, 16 Mar 2018 18:44:47 +0100 Subject: [PATCH] - bugfix extends resource did not work with user defined left/right delimiter https://github.com/smarty-php/smarty/issues/419 --- change_log.txt | 3 +++ libs/Smarty.class.php | 5 ++++- libs/sysplugins/smarty_internal_compile_extends.php | 9 +++++---- libs/sysplugins/smarty_internal_templatecompilerbase.php | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/change_log.txt b/change_log.txt index 81f6f0ef..112bd259 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@ ===== 3.1.32 - dev === +16.03.2018 + - bugfix extends resource did not work with user defined left/right delimiter https://github.com/smarty-php/smarty/issues/419 + 22.11.2017 - bugfix {break} and {continue} could fail if {foreach}{/foreach} did contain other looping tags like {for}, {section} and {while} https://github.com/smarty-php/smarty/issues/323 diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 3e84d0ec..c9b2bb66 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -112,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.32-dev-38'; + const SMARTY_VERSION = '3.1.32-dev-39'; /** * define variable scopes */ @@ -1270,6 +1270,7 @@ class Smarty extends Smarty_Internal_TemplateBase * @param string $name property name * * @return mixed + * @throws \SmartyException */ public function __get($name) { @@ -1293,6 +1294,8 @@ class Smarty extends Smarty_Internal_TemplateBase * * @param string $name property name * @param mixed $value parameter passed to setter + * + * @throws \SmartyException */ public function __set($name, $value) { diff --git a/libs/sysplugins/smarty_internal_compile_extends.php b/libs/sysplugins/smarty_internal_compile_extends.php index 58416661..37bf8dd3 100644 --- a/libs/sysplugins/smarty_internal_compile_extends.php +++ b/libs/sysplugins/smarty_internal_compile_extends.php @@ -135,16 +135,17 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inh /** * Create source code for {extends} from source components array * - * @param []\Smarty_Internal_Template_Source $components + * @param \Smarty_Internal_Template $template * * @return string */ - public static function extendsSourceArrayCode($components) + public static function extendsSourceArrayCode(Smarty_Internal_Template $template) { $resources = array(); - foreach ($components as $source) { + foreach ($template->source->components as $source) { $resources[] = $source->resource; } - return '{extends file=\'extends:' . join('|', $resources) . '\' extends_resource=true}'; + return $template->smarty->left_delimiter . 'extends file=\'extends:' . join('|', $resources) . + '\' extends_resource=true' . $template->smarty->right_delimiter; } } diff --git a/libs/sysplugins/smarty_internal_templatecompilerbase.php b/libs/sysplugins/smarty_internal_templatecompilerbase.php index ed2edf97..d4b0fab4 100644 --- a/libs/sysplugins/smarty_internal_templatecompilerbase.php +++ b/libs/sysplugins/smarty_internal_templatecompilerbase.php @@ -394,7 +394,7 @@ abstract class Smarty_Internal_TemplateCompilerBase // we have array of inheritance templates by extends: resource // generate corresponding source code sequence $_content = - Smarty_Internal_Compile_Extends::extendsSourceArrayCode($this->template->source->components); + Smarty_Internal_Compile_Extends::extendsSourceArrayCode($this->template); } else { // get template source $_content = $this->template->source->getContent();