Frage

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.

Keine korrekte Lösung

Andere Tipps

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);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top