diff options
| author | Simon Wisselink <s.wisselink@iwink.nl> | 2024-06-16 21:48:14 +0200 |
|---|---|---|
| committer | Simon Wisselink <s.wisselink@iwink.nl> | 2024-06-16 21:48:14 +0200 |
| commit | 8ecde472033468efe0149eee53043cfb4fdc6121 (patch) | |
| tree | 323c5fb4250eed728f3ff52dbfef342d617613e6 | |
| parent | b978cb348ee556943bfb252e016059aefd1f4071 (diff) | |
| download | smarty-8ecde472033468efe0149eee53043cfb4fdc6121.tar.gz smarty-8ecde472033468efe0149eee53043cfb4fdc6121.tar.bz2 smarty-8ecde472033468efe0149eee53043cfb4fdc6121.zip | |
fixed error when using section with nocache.
Fixes #1034
| -rw-r--r-- | changelog/1034.md | 1 | ||||
| -rw-r--r-- | src/Compile/Tag/Section.php | 2 | ||||
| -rw-r--r-- | src/Compile/Tag/SectionClose.php | 2 | ||||
| -rw-r--r-- | tests/UnitTests/TemplateSource/TagTests/Section/CompileSectionTest.php | 6 |
4 files changed, 9 insertions, 2 deletions
diff --git a/changelog/1034.md b/changelog/1034.md new file mode 100644 index 00000000..1c14a860 --- /dev/null +++ b/changelog/1034.md @@ -0,0 +1 @@ +- Fixed error when using section with nocache [#1034](https://github.com/smarty-php/smarty/issues/1034)
\ No newline at end of file diff --git a/src/Compile/Tag/Section.php b/src/Compile/Tag/Section.php index f82ac421..13659117 100644 --- a/src/Compile/Tag/Section.php +++ b/src/Compile/Tag/Section.php @@ -99,7 +99,7 @@ class Section extends ForeachSection { if ($compiler->tag_nocache) { // push a {nocache} tag onto the stack to prevent caching of this block - $this->openTag('nocache'); + $this->openTag($compiler, 'nocache'); } $this->openTag($compiler, 'section', ['section', $compiler->tag_nocache]); diff --git a/src/Compile/Tag/SectionClose.php b/src/Compile/Tag/SectionClose.php index efab6097..24c79c32 100644 --- a/src/Compile/Tag/SectionClose.php +++ b/src/Compile/Tag/SectionClose.php @@ -33,7 +33,7 @@ class SectionClose extends Base { if ($nocache_pushed) { // pop the pushed virtual nocache tag - $this->closeTag('nocache'); + $this->closeTag($compiler, 'nocache'); } $output = "<?php\n"; diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/CompileSectionTest.php b/tests/UnitTests/TemplateSource/TagTests/Section/CompileSectionTest.php index c8cb33b4..b2bc2a48 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Section/CompileSectionTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Section/CompileSectionTest.php @@ -148,4 +148,10 @@ class CompileSectionTest extends PHPUnit_Smarty ); } + public function testSectionWithNocache() + { + $source = 'string:{section name=module start=0 loop=1 nocache}{/section}'; + $this->assertEquals('', $this->smarty->fetch($source)); + } + } |
