mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-03 01:44:26 +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:
|
case self::SCOPE_LOCAL:
|
||||||
default:
|
default:
|
||||||
if (isset($this->tpl_vars[$tpl_var])) {
|
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) {
|
if ($nocache) {
|
||||||
$this->tpl_vars[$tpl_var]->setNocache(true);
|
$newVariable->setNocache(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->tpl_vars[$tpl_var] = new Variable($value, $nocache);
|
$newVariable = new Variable($value, $nocache);
|
||||||
}
|
}
|
||||||
|
$this->tpl_vars[$tpl_var] = $newVariable;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@@ -325,4 +325,13 @@ class ScopeTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->assign('scope', 'none');
|
$this->smarty->assign('scope', 'none');
|
||||||
$r = $this->smarty->fetch('test_function_scope.tpl');
|
$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