PCRE Error on PHP 5.2.x

Recent upgrade to PHP 5.2.8 and PHP 5.2.9 have given me some error on the PCRE/Regex library. That is some sort of bugs I search through the net, so far I still can’t find fixed or patch. After continuously compiling and recompiling of PHP on FreeBSD. I finally found a temporary workaround on the issue.

After upgraded to PHP 5.2.9, I got this error on application that need to use regex/pcre library.


[Thu Jun 11 20:39:15 2009] [error] [client xxx.xxx.xxx.xxx] PHP Warning:  preg_replace() [function.preg-replace]: Internal pcre_fullinfo() error -3 in somefile.php on line 169
[Thu Jun 11 20:39:15 2009] [error] [client xxx.xxx.xxx.xxx] PHP Warning:  preg_match() [function.preg-replace]: Internal pcre_fullinfo() error -3 in somefile.php on line 275

If I run through phpinfo(), I can see PHP is compiled with –with-regex=php. Seem like it’s fine with php regex is configured, and according to PHP 5.2.7 to PHP 5.2.8 upgrade, PCRE is build in PHP package, but unfortunately the error shown is related to PCRE error.

The workaround is recompile the PHP with “-with-pcre-regex=yes”. After recompile your application should work like normal again.

Let me know if you have other workaround.