Summary: preg_replace with /e modifier deprecated
Created: 2013-08-06 11:51
OS: Linux, Apache, PHP 5.5.0
Please see Troubleshooting on how to find out which recipes cause the warnings to appear.
Description: On my webserver, I cannot use pmwiki any more because Apache's mod_sec module blocks the invocations of preg_replace with the /e modifier. Since the use of /e is highly discouraged as of PHP 5.5.0, see http://php.net/manual/en/reference.pcre.pattern.modifiers.php, it would be great if pmwiki could be updated.
Or: Multiple messages appear: "Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in pmwiki.php on line 1663"
There is a work in progress and the core shouldn't rely on this deprecated feature as of PmWiki version 2.2.56. We'll migrate any needed modules progressively. Please test the latest version and report any problems. --Petko September 30, 2013, at 04:37 PM
Is the version 2.2.56 working without any modules/recipes/customizations enabled? If yes, which recipes, when enabled, cause the problem? If no, I'd like to test that server in real time, please contact me at 5ko [snail] 5ko [period] fr. --Petko October 28, 2013, at 03:45 PM
OK, found the problem. I used an old version of pagestoreGZ. After disabling it and adding "error_reporting(E_ALL & ~E_DEPRECATED ^ E_NOTICE); " to pmwiki.php it worked again. Thanks nevertheless. Karl Loncarek? October 29, 2013, at 04:01 AM
I'm seeing this in 2.2.61 whenever any of the following, all freshly installed from the cookbook area of PMwiki.org, are enabled:
The current php is - 5.5.7, again freshly installed.
Thanks for your report. I released a new version of Cookbook.AutoTOC which should fix the problem with this recipe. You may try contacting the other authors and ask them to update their recipes for PHP 5.5. --Petko February 05, 2014, at 11:34 AM
To follow up, this was happening on cleanly installed Gentoo system. The php.ini that is getting installed is a development php, which has all warnings and such turned on. Replacing those with production php.ini solved all the issues. My apologies for not realizing that before posting the above. Bob?
Having this problem with multiple messages of Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/cornellbox/cornellbox.com/pmwiki/pmwiki.php on line 1698 Using version 2.2.80 and running PHP 5.6 --psproefrock? Oct 30, 2015
Please follow the instructions at PmWiki.Troubleshooting to find out which recipes need to be updated for PHP 5.6: enable diagnostics then go to pmwiki.php?action=ruleset; alternatively disable all recipes and re-enable them one after another to see which ones cause the warnings to appear. --Petko October 30, 2015, at 11:32 PM
That's very useful. It helped narrow down the problem to the skin I was using and helped get that cleared. --psproefrock? Dec 13, 2015
Problems with specific recipes
I hope this is the right place for this question (I followed the link from Troubleshooting).
I'm updating everything in PHP 5.5 and I am not able to update some recipes by myself: Cluster and Tagger. I asked for help to the author, but she has not time «at the moment, nor in the forseeable future» ( Kathryn Andersen). This puts me in trouble since these two recipes are important to the structure of my site under construction. So I ask for help to the PmWiki's experts, if and when you have time. Thanks in advance. -- Frank - May 15, 2014, at 10:22 PM
I've never used these recipes but I modified them to use the Markup_e() function which is compatible with PHP 5.5 and I don't get "deprecated" warnings. Get Attach:cluster.php and Attach:tagger.php, try them and report any problems (I still haven't used them). --Petko May 15, 2014, at 10:51 PM
Perfect. Both recipes work without problems. Thanks a lot Petko, very fast and accurate... impressive! -- Frank - May 16, 2014, at 03:54 AM
Problems with the blix skin
NOTE: I've now submitted a patch for this (please see ps below)
I found the problem (see below) and created a github ticket, but no response from the author.
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead
ps. in trying to figure out my own solution, I notice that the SkinGuidelines page still shows an example with the now disallowed /e modifier:
The skin maintainer DaveG has been active and very helpful in the PmWiki community for many years. Try contacting him directly via e-mail at "pmwiki (snail) solidgone (period) com". If impossible, as the license of the skin permits modification and distribution, it could be forked. --Petko March 04, 2015, at 08:28 PM
Also finding this problem on the Imagemap recipe. The imagemap.php is only a short file but I have no idea how to amend it. --Dragonfly July 11, 2015, at 10:43 AM
I sent a message to the developer, should be fixed soon. If you're in a hurry, replace line 53:
Markup('area', 'directives', "/\\(:area (.*?)?\\s*?:\\)/e", "MapArea('$1')");
Markup_e('area', 'directives', "/\\(:area (.*?)?\\s*?:\\)/", "MapArea(\$m)");
Or wait for the release of the new version by Hans. --Petko July 11, 2015, at 07:14 AM
That's great, thanks very much! That's also showed me how to fix a couple of others I'd found. Much obliged. --Dragonfly July 21, 2015, at 2:54 PM
If these are recipes from the Cookbook, feel free to contact their authors or leave the solutions at the talk pages. --Petko July 21, 2015, at 09:27 AM
Also finding this problem on the flash, flash2, swf-sites, swf recipe. Where can i find help to correct the problem.
In swf.php i tried to change this line :
"/\\b(?>(\\L))([^\\s$UrlExcludeChars]+\\.swf)/e", "Keep(\$GLOBALS['LinkFunctions']['$1'](\$pagename,'$1','$1',NULL,'$1$2', \$GLOBALS['SwfTagFmt']), 'L')");
"/\\b(?>(\\L))([^\\s$UrlExcludeChars]+\\.swf)/", "Keep(\$GLOBALS['LinkFunctions'][\$m](\$pagename,\$m,\$m,NULL,\$m\$m, \$GLOBALS['SwfTagFmt']), 'L')");
but I generated unexpected '$m' (T_VARIABLE) error .
At the end of the third line, there should be a dot between \$m and \$m:
In Flash.php i tried to change this line :
Markup('flash', '<img', "/\\(:flash (.*?:)(.*?)(\\s.*?)?\\s*?:\\)/e", "ShowFlash('$1','$2','$3')");
Markup_e('flash', '<img', "/\\(:flash (.*?:)(.*?)(\\s.*?)?\\s*?:\\)", "ShowFlash('$1','$2','$3')");
This time, there is no error but it does not embed my swf file in my page. I don't understand what are the '$1' etc and if i must change them by \$m (which changes nothing) or in another variable.
--Jvamp January 25, 2016, at 01:30 AM Dec 12, 2015, at 00:57 AM
Yes, you should change '$1' to \$m, also note you have deleted the last "/e", you should only delete "e" and keep "/":
Note, this should fix your Markup_e() calls without errors, but I haven't tested the modules. --Petko December 11, 2015, at 08:00 PM
For Flash, it works!!! Thanks a lot.
So the correct code is
"/\\b(?>(\\L))([^\\s$UrlExcludeChars]+\\.swf)/", "Keep(\$GLOBALS['LinkFunctions'][\$m](\$pagename,\$m,\$m,NULL,\$m.\$m, \$GLOBALS['SwfTagFmt']), 'L')");
Should i change flash.php in the cookbook ?
--Jvamp January 25, 2016, at 01:30 AM Dec 13, 2015, at 11:01 AM
Try to contact the maintainers via e-mail if you can, and/or write to the talk page. If they cannot update their modules, and if the license permits modification and redistribution, feel free to upload the correct files (make sure you have tested them well). Otherwise you may link to this page so someone else needing the modules can find the informaiton. --Petko December 12, 2015, at 04:13 AM