Question

The PHP Template Engine: Smarty 2.6.0 (/includes/Smarty) is using a deprecated modifier 'e' for preg_replace function call:

Block causing error: /include/Smarty/Smarty_Compiler.class.php @ line 262

/* replace special blocks by "{php}" */
$source_content = preg_replace($search.'e', "'"
. $this->_quote_replace($this->left_delimiter) . 'php'
. "' . str_repeat(\"\n\", substr_count('\\0', \"\n\")) .'"
. $this->_quote_replace($this->right_delimiter)
. "'"
, $source_content);

if you try simply to upgrade Smarty to the current version 3.1.16, or the closest available version 2.6.28. it will not work.

Here comes solution:

So I applied substitute call recommanded by PHP reference. Change: /include/Smarty/Smarty_Compiler.class.php @ line 262

/* replace special blocks by "{php}" */
$source_content = preg_replace_callback($search, 
function($m) { 
    return "{php ".str_repeat("\n", substr_count($m[0], "\n"))."}";
},
$source_content);

I hope this will help someone else and save him few hours.

No correct solution

OTHER TIPS

The following code should allow for other Smarty delimiter tags to be used with your substitution:

$source_content = preg_replace_callback($search,
                                        function($m) {
                                        return $this->_quote_replace($this->left_delimiter)."php ".str_repeat("\n", substr_count($m[0], "\n")).$this->_quote_replace($this->right_delimiter);
                                        },
                                        $source_content);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top