Replace caused blank content because of Wrong parameter count for preg_replace()
jongrimm - March 15, 2009 - 09:35
| Project: | Search and Replace Scanner |
| Version: | 6.x-1.0 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
Running replace on my content caused my content to go completely blank. In the error log, I found the following error:
Wrong parameter count for preg_replace() in \sites\all\modules\scanner\scanner.module on line 877.
Current 6.x-1.0 code includes the use of the count variable on preg_replace, but that was only offered starting with php 5.1.0.
I created this patch to do a version check and if prior to 5.1.0 get the count via preg_match_all() before the replace. This will maintain all current functionality and make it compatible with PHP4.

#1
Suggested patch is attached.
#2
#3
Many thanks, Jon. I'll try to review and commit the patch as soon as I dig out from a pile of work!
#4
Sorry for the slow response. I don't have PHP4 set up on a machine, so I can't test out this patch. Can anyone else using Search and Replace Scanner with PHP4 please test and let me know if it passes? Thanks!