mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-03 18:04:26 +02:00
Removed all PHP_VERSION_ID and compare_version checks and conditional code blocks that are now no longer required
This commit is contained in:
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Removed
|
||||
- Dropped support for PHP7.0 and below, so Smarty now requires PHP >=7.1
|
||||
- Dropped support for php asp tags in templates (removed from php since php7.0)
|
||||
- Removed all PHP_VERSION_ID and compare_version checks and conditional code blocks that are now no longer required
|
||||
|
||||
## [3.1.37] - 2021-01-07
|
||||
|
||||
|
@@ -76,11 +76,7 @@ class Smarty_Autoloader
|
||||
self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . DIRECTORY_SEPARATOR;
|
||||
self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR :
|
||||
self::$SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR;
|
||||
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
|
||||
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
|
||||
} else {
|
||||
spl_autoload_register(array(__CLASS__, 'autoload'));
|
||||
}
|
||||
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -23,12 +23,9 @@
|
||||
*/
|
||||
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
|
||||
{
|
||||
static $_double_encode = null;
|
||||
static $_double_encode = true;
|
||||
static $is_loaded_1 = false;
|
||||
static $is_loaded_2 = false;
|
||||
if ($_double_encode === null) {
|
||||
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
||||
}
|
||||
if (!$char_set) {
|
||||
$char_set = Smarty::$_CHARSET;
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
static $_double_encode = null;
|
||||
static $_double_encode = true;
|
||||
static $is_loaded = false;
|
||||
$compiler->template->_checkPlugins(
|
||||
array(
|
||||
@@ -32,9 +32,6 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
|
||||
)
|
||||
)
|
||||
);
|
||||
if ($_double_encode === null) {
|
||||
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
||||
}
|
||||
try {
|
||||
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
||||
$char_set = smarty_literal_compiler_param($params, 2, Smarty::$_CHARSET);
|
||||
|
@@ -20,13 +20,7 @@
|
||||
function smarty_function_escape_special_chars($string)
|
||||
{
|
||||
if (!is_array($string)) {
|
||||
if (version_compare(PHP_VERSION, '5.2.3', '>=')) {
|
||||
$string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false);
|
||||
} else {
|
||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||
$string = htmlspecialchars($string);
|
||||
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
|
||||
}
|
||||
$string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
@@ -196,11 +196,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
*/
|
||||
public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
|
||||
clearstatcache(true, $cached->lock_id);
|
||||
} else {
|
||||
clearstatcache();
|
||||
}
|
||||
clearstatcache(true, $cached->lock_id);
|
||||
if (is_file($cached->lock_id)) {
|
||||
$t = filemtime($cached->lock_id);
|
||||
return $t && (time() - $t < $smarty->locking_timeout);
|
||||
|
@@ -649,12 +649,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
$this->trigger_template_error("Illegal number of parameter in '{$func_name()}'");
|
||||
}
|
||||
if ($func_name === 'empty') {
|
||||
if (!$this->syntaxMatchesVariable($parameter[0]) && version_compare(PHP_VERSION, '5.5.0', '<')) {
|
||||
return '(' . $parameter[ 0 ] . ' === false )';
|
||||
} else {
|
||||
return $func_name . '(' .
|
||||
str_replace("')->value", "',null,true,false)->value", $parameter[ 0 ]) . ')';
|
||||
}
|
||||
return $func_name . '(' .
|
||||
str_replace("')->value", "',null,true,false)->value", $parameter[ 0 ]) . ')';
|
||||
} else {
|
||||
return $func_name . '(' . $parameter[ 0 ] . ')';
|
||||
}
|
||||
|
@@ -403,11 +403,7 @@ class ConfigVarTest extends PHPUnit_Smarty
|
||||
$this->assertEquals("", $this->smarty->fetch('foo.tpl'));
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (PHP_VERSION_ID >= 80000) {
|
||||
$this->assertStringStartsWith('Undefined variable', $e->getMessage());
|
||||
} else {
|
||||
$this->assertStringStartsWith('Undefined variable', $e->getMessage());
|
||||
}
|
||||
$this->assertStringStartsWith('Undefined variable', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -170,9 +170,6 @@ echo \'bar \';
|
||||
$foo = 3;
|
||||
{ /php}<--', 'PHP_ALLOW, \'phptag_literal.tpl\''),
|
||||
);
|
||||
if (version_compare(phpversion(), '5.7.0', '<')) {
|
||||
$data[] = array(Smarty::PHP_ALLOW, 'script.tpl', '<br> This is a script <br> 5<br>', 'PHP_ALLOW, \'script.tpl\'');
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
/*
|
||||
|
Reference in New Issue
Block a user