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

jongrimm - March 15, 2009 - 09:40

Suggested patch is attached.

AttachmentSize
scanner-402434-1.patch 1.1 KB

#2

jongrimm - March 15, 2009 - 09:40
Status:active» needs review

#3

aasarava - March 20, 2009 - 03:05

Many thanks, Jon. I'll try to review and commit the patch as soon as I dig out from a pile of work!

#4

aasarava - May 8, 2009 - 16:46

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!

 
 

Drupal is a registered trademark of Dries Buytaert.