mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-03 09:54:27 +02:00
1
changelog/952.md
Normal file
1
changelog/952.md
Normal file
@@ -0,0 +1 @@
|
||||
- Fixed that scoped variables would overwrite parent scope [#952](https://github.com/smarty-php/smarty/issues/952)
|
@@ -127,13 +127,15 @@ class Data
|
||||
case self::SCOPE_LOCAL:
|
||||
default:
|
||||
if (isset($this->tpl_vars[$tpl_var])) {
|
||||
$this->tpl_vars[$tpl_var]->setValue($value);
|
||||
$newVariable = clone $this->tpl_vars[$tpl_var];
|
||||
$newVariable->setValue($value);
|
||||
if ($nocache) {
|
||||
$this->tpl_vars[$tpl_var]->setNocache(true);
|
||||
$newVariable->setNocache(true);
|
||||
}
|
||||
} else {
|
||||
$this->tpl_vars[$tpl_var] = new Variable($value, $nocache);
|
||||
$newVariable = new Variable($value, $nocache);
|
||||
}
|
||||
$this->tpl_vars[$tpl_var] = $newVariable;
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@@ -325,4 +325,13 @@ class ScopeTest extends PHPUnit_Smarty
|
||||
$this->smarty->assign('scope', 'none');
|
||||
$r = $this->smarty->fetch('test_function_scope.tpl');
|
||||
}
|
||||
|
||||
public function testFunctionScopeIsLocaLByDefault()
|
||||
{
|
||||
$this->assertEquals(
|
||||
'a',
|
||||
$this->smarty->fetch('string:{function name=test}{$var="b"}{/function}{$var="a"}{test}{$var}')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user