- performance store flag for already required shared plugin functions in static variable or

Smarty's $_cache to improve performance when plugins are often called
    51e0d5cd40 (commitcomment-22280086)
This commit is contained in:
uwetews
2017-05-27 11:04:00 +02:00
parent a49a08748f
commit e51b0ac4af
13 changed files with 126 additions and 45 deletions

View File

@@ -1,5 +1,8 @@
===== 3.1.32 - dev === ===== 3.1.32 - dev ===
21.5.2017 21.5.2017
- performance store flag for already required shared plugin functions in static variable or
Smarty's $_cache to improve performance when plugins are often called
https://github.com/smarty-php/smarty/commit/51e0d5cd405d764a4ea257d1bac1fb1205f74528#commitcomment-22280086
- bugfix remove special treatment of classes implementing ArrayAccess in {foreach} - bugfix remove special treatment of classes implementing ArrayAccess in {foreach}
https://github.com/smarty-php/smarty/issues/332 https://github.com/smarty-php/smarty/issues/332
- bugfix remove deleted files by clear_cache() and clear_compiled_template() from - bugfix remove deleted files by clear_cache() and clear_compiled_template() from

View File

@@ -108,7 +108,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/** /**
* smarty version * smarty version
*/ */
const SMARTY_VERSION = '3.1.32-dev-7'; const SMARTY_VERSION = '3.1.32-dev-8';
/** /**
* define variable scopes * define variable scopes

View File

@@ -38,8 +38,9 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
if (is_null($content)) { if (is_null($content)) {
return; return;
} }
if (Smarty::$_MBSTRING && !is_callable('smarty_mb_wordwrap')) { if (!isset($template->smarty->_cache[ '_required_smw' ])) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php'); require_once(SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php');
$template->smarty->_cache[ '_required_smw' ] = true;
} }
$style = null; $style = null;
@@ -87,8 +88,10 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
} }
// convert mult. spaces & special chars to single space // convert mult. spaces & special chars to single space
$_paragraph = $_paragraph =
preg_replace(array('!\s+!' . Smarty::$_UTF8_MODIFIER, '!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER), preg_replace(array('!\s+!' . Smarty::$_UTF8_MODIFIER,
array(' ', ''), $_paragraph); '!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER),
array(' ',
''), $_paragraph);
// indent first line // indent first line
if ($indent_first > 0) { if ($indent_first > 0) {
$_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph; $_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph;

View File

@@ -45,8 +45,9 @@
*/ */
function smarty_function_html_checkboxes($params, $template) function smarty_function_html_checkboxes($params, $template)
{ {
if (!is_callable('smarty_function_escape_special_chars')) { if (!isset($template->smarty->_cache[ '_required_sesc' ])) {
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
$template->smarty->_cache[ '_required_sesc' ] = true;
} }
$name = 'checkbox'; $name = 'checkbox';

View File

@@ -38,8 +38,9 @@
*/ */
function smarty_function_html_image($params, $template) function smarty_function_html_image($params, $template)
{ {
if (!is_callable('smarty_function_escape_special_chars')) { if (!isset($template->smarty->_cache[ '_required_sesc' ])) {
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
$template->smarty->_cache[ '_required_sesc' ] = true;
} }
$alt = ''; $alt = '';

View File

@@ -28,15 +28,18 @@
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
* @author Ralf Strehle (minor optimization) <ralf dot strehle at yahoo dot de> * @author Ralf Strehle (minor optimization) <ralf dot strehle at yahoo dot de>
* *
* @param array $params parameters * @param array $params parameters
*
* @param \Smarty_Internal_Template $template
* *
* @return string * @return string
* @uses smarty_function_escape_special_chars() * @uses smarty_function_escape_special_chars()
*/ */
function smarty_function_html_options($params) function smarty_function_html_options($params, Smarty_Internal_Template $template)
{ {
if (!is_callable('smarty_function_escape_special_chars')) { if (!isset($template->smarty->_cache[ '_required_sesc' ])) {
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
$template->smarty->_cache[ '_required_sesc' ] = true;
} }
$name = null; $name = null;

View File

@@ -45,8 +45,9 @@
*/ */
function smarty_function_html_radios($params, $template) function smarty_function_html_radios($params, $template)
{ {
if (!is_callable('smarty_function_escape_special_chars')) { if (!isset($template->smarty->_cache[ '_required_sesc' ])) {
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
$template->smarty->_cache[ '_required_sesc' ] = true;
} }
$name = 'radio'; $name = 'radio';

View File

@@ -37,17 +37,21 @@
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
* @author Rodney Rehm * @author Rodney Rehm
* *
* @param array $params parameters * @param array $params parameters
*
* @param \Smarty_Internal_Template $template
* *
* @return string * @return string
*/ */
function smarty_function_html_select_date($params) function smarty_function_html_select_date($params, Smarty_Internal_Template $template)
{ {
if (!is_callable('smarty_function_escape_special_chars')) { if (!isset($template->smarty->_cache[ '_required_sesc' ])) {
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
$template->smarty->_cache[ '_required_sesc' ] = true;
} }
if (!is_callable('smarty_make_timestamp')) { if (!isset($template->smarty->_cache[ '_required_smt' ])) {
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'); require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
$template->smarty->_cache[ '_required_smt' ] = true;
} }
// generate timestamps used for month names only // generate timestamps used for month names only
static $_month_timestamps = null; static $_month_timestamps = null;
@@ -177,7 +181,9 @@ function smarty_function_html_select_date($params)
if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) { if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) {
if (isset($params[ 'time' ][ $prefix . 'Year' ])) { if (isset($params[ 'time' ][ $prefix . 'Year' ])) {
// $_REQUEST[$field_array] given // $_REQUEST[$field_array] given
foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) { foreach (array('Y' => 'Year',
'm' => 'Month',
'd' => 'Day') as $_elementKey => $_elementName) {
$_variableName = '_' . strtolower($_elementName); $_variableName = '_' . strtolower($_elementName);
$$_variableName = $$_variableName =
isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] : isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] :
@@ -185,7 +191,9 @@ function smarty_function_html_select_date($params)
} }
} elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Year' ])) { } elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Year' ])) {
// $_REQUEST given // $_REQUEST given
foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) { foreach (array('Y' => 'Year',
'm' => 'Month',
'd' => 'Day') as $_elementKey => $_elementName) {
$_variableName = '_' . strtolower($_elementName); $_variableName = '_' . strtolower($_elementName);
$$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ? $$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ?
$params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey); $params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey);
@@ -206,7 +214,8 @@ function smarty_function_html_select_date($params)
// make syntax "+N" or "-N" work with $start_year and $end_year // make syntax "+N" or "-N" work with $start_year and $end_year
// Note preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match) is slower than trim+substr // Note preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match) is slower than trim+substr
foreach (array('start', 'end') as $key) { foreach (array('start',
'end') as $key) {
$key .= '_year'; $key .= '_year';
$t = $$key; $t = $$key;
if ($t === null) { if ($t === null) {

View File

@@ -17,18 +17,22 @@
* @author Roberto Berto <roberto@berto.net> * @author Roberto Berto <roberto@berto.net>
* @author Monte Ohrt <monte AT ohrt DOT com> * @author Monte Ohrt <monte AT ohrt DOT com>
* *
* @param array $params parameters * @param array $params parameters
*
* @param \Smarty_Internal_Template $template
* *
* @return string * @return string
* @uses smarty_make_timestamp() * @uses smarty_make_timestamp()
*/ */
function smarty_function_html_select_time($params) function smarty_function_html_select_time($params, Smarty_Internal_Template $template)
{ {
if (!is_callable('smarty_function_escape_special_chars')) { if (!isset($template->smarty->_cache[ '_required_sesc' ])) {
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
$template->smarty->_cache[ '_required_sesc' ] = true;
} }
if (!is_callable('smarty_make_timestamp')) { if (!isset($template->smarty->_cache[ '_required_smt' ])) {
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'); require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
$template->smarty->_cache[ '_required_smt' ] = true;
} }
$prefix = "Time_"; $prefix = "Time_";
$field_array = null; $field_array = null;
@@ -148,7 +152,9 @@ function smarty_function_html_select_time($params)
if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) { if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) {
if (isset($params[ 'time' ][ $prefix . 'Hour' ])) { if (isset($params[ 'time' ][ $prefix . 'Hour' ])) {
// $_REQUEST[$field_array] given // $_REQUEST[$field_array] given
foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) { foreach (array('H' => 'Hour',
'i' => 'Minute',
's' => 'Second') as $_elementKey => $_elementName) {
$_variableName = '_' . strtolower($_elementName); $_variableName = '_' . strtolower($_elementName);
$$_variableName = $$_variableName =
isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] : isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] :
@@ -161,7 +167,9 @@ function smarty_function_html_select_time($params)
list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time)); list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time));
} elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Hour' ])) { } elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Hour' ])) {
// $_REQUEST given // $_REQUEST given
foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) { foreach (array('H' => 'Hour',
'i' => 'Minute',
's' => 'Second') as $_elementKey => $_elementName) {
$_variableName = '_' . strtolower($_elementName); $_variableName = '_' . strtolower($_elementName);
$$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ? $$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ?
$params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey); $params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey);
@@ -350,7 +358,10 @@ function smarty_function_html_select_time($params)
} }
$_html = ''; $_html = '';
foreach (array('_html_hours', '_html_minutes', '_html_seconds', '_html_meridian') as $k) { foreach (array('_html_hours',
'_html_minutes',
'_html_seconds',
'_html_meridian') as $k) {
if (isset($$k)) { if (isset($$k)) {
if ($_html) { if ($_html) {
$_html .= $field_separator; $_html .= $field_separator;

View File

@@ -35,8 +35,12 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
/** /**
* require_once the {@link shared.make_timestamp.php} plugin * require_once the {@link shared.make_timestamp.php} plugin
*/ */
if (!is_callable('smarty_make_timestamp')) { static $is_loaded = false;
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'); if (!$is_loaded) {
if (!is_callable('smarty_make_timestamp')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
}
$is_loaded = true;
} }
if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') { if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') {
$timestamp = smarty_make_timestamp($string); $timestamp = smarty_make_timestamp($string);
@@ -47,8 +51,20 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
} }
if ($formatter == 'strftime' || ($formatter == 'auto' && strpos($format, '%') !== false)) { if ($formatter == 'strftime' || ($formatter == 'auto' && strpos($format, '%') !== false)) {
if (Smarty::$_IS_WINDOWS) { if (Smarty::$_IS_WINDOWS) {
$_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T'); $_win_from = array('%D',
$_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S'); '%h',
'%n',
'%r',
'%R',
'%t',
'%T');
$_win_to = array('%m/%d/%y',
'%b',
"\n",
'%I:%M:%S %p',
'%H:%M',
"\t",
'%H:%M:%S');
if (strpos($format, '%e') !== false) { if (strpos($format, '%e') !== false) {
$_win_from[] = '%e'; $_win_from[] = '%e';
$_win_to[] = sprintf('%\' 2d', date('j', $timestamp)); $_win_to[] = sprintf('%\' 2d', date('j', $timestamp));

View File

@@ -25,6 +25,8 @@
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true) function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
{ {
static $_double_encode = null; static $_double_encode = null;
static $is_loaded1 = false;
static $is_loaded2 = false;
if ($_double_encode === null) { if ($_double_encode === null) {
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>='); $_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
} }
@@ -46,7 +48,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
// php <5.2.3 - prevent double encoding // php <5.2.3 - prevent double encoding
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
$string = htmlspecialchars($string, ENT_QUOTES, $char_set); $string = htmlspecialchars($string, ENT_QUOTES, $char_set);
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); $string = str_replace(array('%%%SMARTY_START%%%',
'%%%SMARTY_END%%%'), array('&',
';'), $string);
return $string; return $string;
} }
@@ -67,7 +71,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
$string = htmlspecialchars($string, ENT_QUOTES, $char_set); $string = htmlspecialchars($string, ENT_QUOTES, $char_set);
$string = $string =
str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); str_replace(array('%%%SMARTY_START%%%',
'%%%SMARTY_END%%%'), array('&',
';'), $string);
return $string; return $string;
} }
@@ -86,7 +92,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
} else { } else {
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
$string = htmlentities($string, ENT_QUOTES, $char_set); $string = htmlentities($string, ENT_QUOTES, $char_set);
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); $string = str_replace(array('%%%SMARTY_START%%%',
'%%%SMARTY_END%%%'), array('&',
';'), $string);
return $string; return $string;
} }
@@ -116,8 +124,11 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
case 'hexentity': case 'hexentity':
$return = ''; $return = '';
if (Smarty::$_MBSTRING) { if (Smarty::$_MBSTRING) {
if (!is_callable('smarty_mb_to_unicode')) { if (!$is_loaded1) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php'); if (!is_callable('smarty_mb_to_unicode')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
$is_loaded1 = true;
}
} }
$return = ''; $return = '';
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) { foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
@@ -137,8 +148,11 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
case 'decentity': case 'decentity':
$return = ''; $return = '';
if (Smarty::$_MBSTRING) { if (Smarty::$_MBSTRING) {
if (!is_callable('smarty_mb_to_unicode')) { if (!$is_loaded1) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php'); if (!is_callable('smarty_mb_to_unicode')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
}
$is_loaded1 = true;
} }
$return = ''; $return = '';
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) { foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
@@ -157,7 +171,11 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
case 'javascript': case 'javascript':
// escape quotes and backslashes, newlines, etc. // escape quotes and backslashes, newlines, etc.
return strtr($string, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', return strtr($string, array('\\' => '\\\\',
"'" => "\\'",
'"' => '\\"',
"\r" => '\\r',
"\n" => '\\n',
'</' => '<\/')); '</' => '<\/'));
case 'mail': case 'mail':
@@ -165,17 +183,24 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
if (!is_callable('smarty_mb_str_replace')) { if (!is_callable('smarty_mb_str_replace')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'); require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
} }
return smarty_mb_str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string); return smarty_mb_str_replace(array('@',
'.'), array(' [AT] ',
' [DOT] '), $string);
} }
// no MBString fallback // no MBString fallback
return str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string); return str_replace(array('@',
'.'), array(' [AT] ',
' [DOT] '), $string);
case 'nonstd': case 'nonstd':
// escape non-standard chars, such as ms document quotes // escape non-standard chars, such as ms document quotes
$return = ''; $return = '';
if (Smarty::$_MBSTRING) { if (Smarty::$_MBSTRING) {
if (!is_callable('smarty_mb_to_unicode')) { if (!$is_loaded1) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php'); if (!is_callable('smarty_mb_to_unicode')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
}
$is_loaded1 = true;
} }
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) { foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
if ($unicode >= 126) { if ($unicode >= 126) {

View File

@@ -24,11 +24,15 @@
*/ */
function smarty_modifier_replace($string, $search, $replace) function smarty_modifier_replace($string, $search, $replace)
{ {
static $is_loaded = false;
if (Smarty::$_MBSTRING) { if (Smarty::$_MBSTRING) {
if (!is_callable('smarty_mb_str_replace')) { if (!$is_loaded) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'); if (!is_callable('smarty_mb_str_replace')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
}
$is_loaded = true;
} }
return smarty_mb_str_replace($search, $replace, $string); return smarty_mb_str_replace($search, $replace, $string);
} }
return str_replace($search, $replace, $string); return str_replace($search, $replace, $string);

View File

@@ -23,8 +23,12 @@
function smarty_modifiercompiler_escape($params, $compiler) function smarty_modifiercompiler_escape($params, $compiler)
{ {
static $_double_encode = null; static $_double_encode = null;
if (!is_callable('smarty_literal_compiler_param')) { static $is_loaded = false;
require_once(SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php'); if (!$is_loaded) {
if (!is_callable('smarty_literal_compiler_param')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php');
}
$is_loaded = true;
} }
if ($_double_encode === null) { if ($_double_encode === null) {
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>='); $_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');