Skip to content

Commit

Permalink
replace functions deprecated in PHP 7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
uwetews committed Nov 3, 2017
1 parent 23d29f2 commit 4ab9757
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions libs/Smarty.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @author Monte Ohrt <monte at ohrt dot com>
* @author Andrei Zmievski <andrei@php.net>
* @package Smarty
* @version 2.6.30
* @version 2.6.31-dev
*/

/* $Id$ */
Expand Down Expand Up @@ -465,7 +465,7 @@ class Smarty
*
* @var string
*/
var $_version = '2.6.30';
var $_version = '2.6.31';

/**
* current template inclusion depth
Expand Down
16 changes: 8 additions & 8 deletions libs/Smarty_Compiler.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,9 @@ function _compile_file($resource_name, $source_content, &$compiled_content)

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. */
Expand Down Expand Up @@ -556,7 +551,7 @@ function _compile_tag($template_tag)

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 */
Expand Down Expand Up @@ -754,7 +749,12 @@ function _compile_block_tag($tag_command, $tag_args, $tag_modifier, &$output)
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
*
Expand Down

0 comments on commit 4ab9757

Please sign in to comment.