diff --git a/CHANGELOG.md b/CHANGELOG.md index d44c1fec..3b9989a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/libs/Autoloader.php b/libs/Autoloader.php index c09361b6..e909d434 100644 --- a/libs/Autoloader.php +++ b/libs/Autoloader.php @@ -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); } /** diff --git a/libs/plugins/modifier.escape.php b/libs/plugins/modifier.escape.php index 150901c7..35bf9720 100644 --- a/libs/plugins/modifier.escape.php +++ b/libs/plugins/modifier.escape.php @@ -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; } diff --git a/libs/plugins/modifiercompiler.escape.php b/libs/plugins/modifiercompiler.escape.php index e0763adc..0eabebf8 100644 --- a/libs/plugins/modifiercompiler.escape.php +++ b/libs/plugins/modifiercompiler.escape.php @@ -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); diff --git a/libs/plugins/shared.escape_special_chars.php b/libs/plugins/shared.escape_special_chars.php index 6b18d3ee..a204b092 100644 --- a/libs/plugins/shared.escape_special_chars.php +++ b/libs/plugins/shared.escape_special_chars.php @@ -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; } diff --git a/libs/sysplugins/smarty_internal_cacheresource_file.php b/libs/sysplugins/smarty_internal_cacheresource_file.php index 61618449..abed98d8 100644 --- a/libs/sysplugins/smarty_internal_cacheresource_file.php +++ b/libs/sysplugins/smarty_internal_cacheresource_file.php @@ -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); diff --git a/libs/sysplugins/smarty_internal_templatecompilerbase.php b/libs/sysplugins/smarty_internal_templatecompilerbase.php index 3cc957de..3f6b1668 100644 --- a/libs/sysplugins/smarty_internal_templatecompilerbase.php +++ b/libs/sysplugins/smarty_internal_templatecompilerbase.php @@ -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 ] . ')'; } diff --git a/tests/UnitTests/ConfigFileTests/file/ConfigVarTest.php b/tests/UnitTests/ConfigFileTests/file/ConfigVarTest.php index 465b4966..b4f9473d 100644 --- a/tests/UnitTests/ConfigFileTests/file/ConfigVarTest.php +++ b/tests/UnitTests/ConfigFileTests/file/ConfigVarTest.php @@ -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()); } } } diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/CompilePhpTest.php b/tests/UnitTests/TemplateSource/TagTests/Php/CompilePhpTest.php index cfb4f152..d2a49446 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Php/CompilePhpTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Php/CompilePhpTest.php @@ -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', '
This is a script
5
', 'PHP_ALLOW, \'script.tpl\''); - } return $data; } /*