mirror of
https://github.com/smarty-php/smarty.git
synced 2026-08-11 07:51:32 +02:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7320402766 | ||
|
|
1115eb6f65 | ||
|
|
9656f553d1 | ||
|
|
42b869e3a0 | ||
|
|
4cb00900d7 | ||
|
|
204f3bc74e | ||
|
|
409802db04 | ||
|
|
1015e5472b | ||
|
|
c7a271323b | ||
|
|
e2cb9873ff |
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
- Fixed argument must be passed by reference error introduced in v4.5.1 [#964](https://github.com/smarty-php/smarty/issues/964)
|
||||||
|
|
||||||
|
## [4.5.1] - 2024-03-18
|
||||||
|
|
||||||
|
|
||||||
|
## [4.5.0] - 2024-03-18
|
||||||
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Using unregistered static class methods in expressions now also triggers a deprecation notice because we will drop support for this in the next major release [#813](https://github.com/smarty-php/smarty/issues/813)
|
- Using unregistered static class methods in expressions now also triggers a deprecation notice because we will drop support for this in the next major release [#813](https://github.com/smarty-php/smarty/issues/813)
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = '4.4.1';
|
const SMARTY_VERSION = '4.5.2';
|
||||||
/**
|
/**
|
||||||
* define variable scopes
|
* define variable scopes
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -640,17 +640,18 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||||||
return $func_name . '(' . $parameter[ 0 ] . ')';
|
return $func_name . '(' . $parameter[ 0 ] . ')';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$first_param = array_shift($parameter);
|
|
||||||
$modifier = array_merge(array($name), $parameter);
|
if (
|
||||||
// Now, compile the function call as a modifier
|
!$this->smarty->loadPlugin('smarty_modifiercompiler_' . $name)
|
||||||
return $this->compileTag(
|
&& !isset($this->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$name])
|
||||||
'private_modifier',
|
&& !in_array($name, ['time', 'join', 'is_array', 'in_array'])
|
||||||
array(),
|
) {
|
||||||
array(
|
trigger_error('Using unregistered function "' . $name . '" in a template is deprecated and will be ' .
|
||||||
'modifierlist' => array($modifier),
|
'removed in a future release. Use Smarty::registerPlugin to explicitly register ' .
|
||||||
'value' => $first_param
|
'a custom modifier.', E_USER_DEPRECATED);
|
||||||
)
|
}
|
||||||
);
|
|
||||||
|
return $name . '(' . implode(',', $parameter) . ')';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->trigger_template_error("unknown function '{$name}'");
|
$this->trigger_template_error("unknown function '{$name}'");
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ php utilities/update-smarty-version-number.php $1
|
|||||||
git add changelog CHANGELOG.md libs/Smarty.class.php
|
git add changelog CHANGELOG.md libs/Smarty.class.php
|
||||||
git commit -m "version bump"
|
git commit -m "version bump"
|
||||||
|
|
||||||
git checkout support/4.3
|
git checkout support/4
|
||||||
git pull
|
git pull
|
||||||
git merge --no-ff "release/$1"
|
git merge --no-ff "release/$1"
|
||||||
git branch -d "release/$1"
|
git branch -d "release/$1"
|
||||||
|
|||||||
@@ -299,4 +299,12 @@ 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()
|
||||||
|
{
|
||||||
|
$r = $this->smarty->fetch('string:{function name=test}{$var="b"}{/function}{$var="a"}{test}{$var}');
|
||||||
|
$this->assertEquals('a', $r);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class ArgumentMustBePassedByReference961Test extends PHPUnit_Smarty
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group issue961
|
||||||
|
*/
|
||||||
|
public function testReset()
|
||||||
|
{
|
||||||
|
$smarty = new Smarty();
|
||||||
|
$smarty->registerPlugin('modifier', 'reset', 'reset');
|
||||||
|
$templateStr = "string:{reset(\$ar)}";
|
||||||
|
$smarty->assign('ar', [1,2,3]);
|
||||||
|
$this->assertEquals(
|
||||||
|
'1',
|
||||||
|
$smarty->fetch($templateStr)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group issue961
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public function testResetAsModifier()
|
||||||
|
{
|
||||||
|
$smarty = new Smarty();
|
||||||
|
try {
|
||||||
|
$templateStr = "string:{\$ar|reset}";
|
||||||
|
$smarty->assign('ar', [1,2,3]);
|
||||||
|
$this->assertEquals(
|
||||||
|
'1',
|
||||||
|
$smarty->fetch($templateStr)
|
||||||
|
);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group issue961
|
||||||
|
*/
|
||||||
|
public function testResetInExpression()
|
||||||
|
{
|
||||||
|
$smarty = new Smarty();
|
||||||
|
$smarty->registerPlugin('modifier', 'reset', 'reset');
|
||||||
|
$templateStr = "string:{if reset(\$ar)}ok{/if}";
|
||||||
|
$smarty->assign('ar', [1,2,3]);
|
||||||
|
$this->assertEquals(
|
||||||
|
'ok',
|
||||||
|
$smarty->fetch($templateStr)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group issue961
|
||||||
|
*/
|
||||||
|
public function testMatch()
|
||||||
|
{
|
||||||
|
$smarty = new Smarty();
|
||||||
|
$smarty->registerPlugin('modifier', 'preg_match', 'preg_match');
|
||||||
|
$templateStr = 'string:{assign var="match" value=null}{if preg_match(\'/([a-z]{4})/\', "a test", $match)}{$match.1}{/if}';
|
||||||
|
$this->assertEquals(
|
||||||
|
'test',
|
||||||
|
$smarty->fetch($templateStr)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user