diff --git a/ChangeLog b/ChangeLog index a019e935..02ab60f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +===== 2.6.31 === +2017-11-03 + * replace functions deprecated in PHP 7.2 + + 2016-09-11 Uwe Tews * {math} fix parameter checking order to avoid misleading message * {math} replace wrong versiom diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 41d53706..3c97b5fd 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -27,7 +27,7 @@ * @author Monte Ohrt * @author Andrei Zmievski * @package Smarty - * @version 2.6.30 + * @version 2.6.31-dev */ /* $Id$ */ @@ -465,7 +465,7 @@ class Smarty * * @var string */ - var $_version = '2.6.30'; + var $_version = '2.6.31'; /** * current template inclusion depth diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index 00602150..904601d7 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -259,14 +259,9 @@ class Smarty_Compiler extends Smarty { preg_match_all($search, $source_content, $match, PREG_SET_ORDER); $this->_folded_blocks = $match; - reset($this->_folded_blocks); /* replace special blocks by "{php}" */ - $source_content = preg_replace_callback($search, create_function ('$matches', "return '" - . $this->_quote_replace($this->left_delimiter) . 'php' - . "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'" - . $this->_quote_replace($this->right_delimiter) - . "';") + $source_content = preg_replace_callback($search, array($this,'_preg_callback') , $source_content); /* Gather all template tags. */ @@ -556,7 +551,7 @@ class Smarty_Compiler extends Smarty { case 'php': /* handle folded tags replaced by {php} */ - list(, $block) = each($this->_folded_blocks); + $block = array_shift($this->_folded_blocks); $this->_current_line_no += substr_count($block[0], "\n"); /* the number of matched elements in the regexp in _compile_file() determins the type of folded tag that was found */ @@ -754,7 +749,12 @@ class Smarty_Compiler extends Smarty { return true; } - + function _preg_callback ($matches) { + return $this->_quote_replace($this->left_delimiter) + . 'php' + . str_repeat("\n", substr_count($matches[1], "\n")) + . $this->_quote_replace($this->right_delimiter); + } /** * compile custom function tag *