Question

I'm getting error with Symfony 1.4 Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /vagrant/lib/util/sfToolkit.class.php on line 365

The function concerned is below:

public static function pregtr($search, $replacePairs)
  {
    if(strpos(implode(', ', $replacePairs),'e') > 0)
      print_r($replacePairs);

    return preg_replace(array_keys($replacePairs),array_values($replacePairs), $search);
  }

The values concerned is:

Array
(
    [#/(.?)#e] => '::'.strtoupper('\1')
    [/(^|_|-)+(.)/e] => strtoupper('\2')
)

How can I change this to what is equivalent using preg_replace_callback?

Was it helpful?

Solution

You can try to use the sf 1.5. version maintained by guys from L'Express: https://github.com/LExpress/symfony1 (they have fixed the problem)

If their changes are too much you can check how they managed to solve the 'e modifier' problem and copy their solution. Searching the code for use of pregtr it looks that there are only three places where the e modifier is used (in lib/util/sfInflector.class.php and in filter form classes in the Doctrine and Proper plugins). It's not that difficult to fix the code by yourself in those places.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top