From ecac24d073ee171d8d1f1353a24bcdb4e50caf39 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Mon, 23 Jan 2023 16:40:27 +0100 Subject: [PATCH] Fixed bug in {include} variable assignment and removed some unused/unrequired code --- src/Data.php | 8 ++++---- src/Smarty.php | 12 ------------ src/Template.php | 4 ---- .../TagTests/While/CompileWhileTest.php | 2 +- 4 files changed, 5 insertions(+), 21 deletions(-) diff --git a/src/Data.php b/src/Data.php index eb0308aa..cd4fa3e7 100644 --- a/src/Data.php +++ b/src/Data.php @@ -126,13 +126,13 @@ class Data break; case self::SCOPE_LOCAL: default: - if ($this->hasVariable($tpl_var)) { - $this->getVariable($tpl_var)->setValue($value); + if (isset($this->tpl_vars[$tpl_var])) { + $this->tpl_vars[$tpl_var]->setValue($value); if ($nocache) { - $this->getVariable($tpl_var)->setNocache(true); + $this->tpl_vars[$tpl_var]->setNocache(true); } } else { - $this->tpl_vars[ $tpl_var ] = new Variable($value, $nocache); + $this->tpl_vars[$tpl_var] = new Variable($value, $nocache); } } diff --git a/src/Smarty.php b/src/Smarty.php index 14af6a1e..92fb2538 100644 --- a/src/Smarty.php +++ b/src/Smarty.php @@ -531,12 +531,6 @@ class Smarty extends \Smarty\TemplateBase */ private $BCPluginsAdapter; - /** - * Cache of templates created - * @var array - */ - private $templates; - /** * Initialize new Smarty object */ @@ -1000,12 +994,6 @@ class Smarty extends \Smarty\TemplateBase } $_templateId = $this->generateUniqueTemplateId($template_name, $cache_id, $compile_id, $caching, $baseFilePath); -// if (true || !isset($this->templates[$_templateId])) { -// $this->templates[$_templateId] = new Template($template_name, $this, null, $cache_id, $compile_id, $caching); -// $this->templates[$_templateId]->templateId = $_templateId; -// } -// $tpl = $this->templates[$_templateId]; - $tpl = new Template($template_name, $this, $parent ?: $this, $cache_id, $compile_id, $caching); $tpl->templateId = $_templateId; diff --git a/src/Template.php b/src/Template.php index fca4b03e..a81a81f8 100644 --- a/src/Template.php +++ b/src/Template.php @@ -268,10 +268,6 @@ class Template extends TemplateBase { $tpl->setDefaultScope($scope); } - // copy variables - $tpl->tpl_vars = $this->tpl_vars; - $tpl->config_vars = $this->config_vars; - // recursive call ? if ($tpl->getTemplateId() !== $this->getTemplateId()) { diff --git a/tests/UnitTests/TemplateSource/TagTests/While/CompileWhileTest.php b/tests/UnitTests/TemplateSource/TagTests/While/CompileWhileTest.php index 4ab7f44e..eaabf29b 100644 --- a/tests/UnitTests/TemplateSource/TagTests/While/CompileWhileTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/While/CompileWhileTest.php @@ -120,7 +120,7 @@ class CompileWhileTest extends PHPUnit_Smarty } /* - * Data provider für testNocache + * Data provider for testNocache */ public function dataTestNocache() {