Skip to content

Commit

Permalink
fixed error when using section with nocache.
Browse files Browse the repository at this point in the history
Fixes #1034
  • Loading branch information
wisskid committed Jun 16, 2024
1 parent b978cb3 commit 8ecde47
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog/1034.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixed error when using section with nocache [#1034](https://github.com/smarty-php/smarty/issues/1034)
2 changes: 1 addition & 1 deletion src/Compile/Tag/Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function compile($args, \Smarty\Compiler\Template $compiler, $parameter =

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]);
Expand Down
2 changes: 1 addition & 1 deletion src/Compile/Tag/SectionClose.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function compile($args, \Smarty\Compiler\Template $compiler, $parameter =

if ($nocache_pushed) {
// pop the pushed virtual nocache tag
$this->closeTag('nocache');
$this->closeTag($compiler, 'nocache');
}

$output = "<?php\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,10 @@ public function dataTestElseSpacing()
);
}

public function testSectionWithNocache()
{
$source = 'string:{section name=module start=0 loop=1 nocache}{/section}';
$this->assertEquals('', $this->smarty->fetch($source));
}

}

0 comments on commit 8ecde47

Please sign in to comment.