From: Sjon at hortensius dot net
Operating system: linux 2.6.21.5
PHP version: 5.2.3
PHP Bug Type: Regexps related
Bug description: preg_replace_callback returns NULL instead of input or error
Description:
------------
The preg_replace_callback manual-entry says:
If matches are found, the new subject will be returned, otherwise subject
will be returned unchanged.
However; I have a testcase where no input is returned; and my callback
isn't called either. This seems to be caused by a required
pcre.backtrack_limit of 10000000
Shouldn't PHP return the input or an error giving some pointers about this
limit being reached?
Reproduce code:
---------------
<?PHP
$input = '{?value==input.value}';
$regexp = '~\{\?(?:\(?!?.+(==)?.+\)?)+\}{\1\/}~sU';
var_dump(preg_replace_callback($regexp, 'callback', $input));
function callback(){
die('called');
}
Expected result:
----------------
I expect an error to be raised when pcre.backtrack_limit is reached
Actual result:
--------------
NULL is var_dumped
--
Edit bug report at http://bugs.php.net/?id=41788&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=41788&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=41788&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=41788&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41788&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=41788&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41788&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41788&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41788&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41788&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41788&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=41788&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=41788&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41788&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41788&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41788&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41788&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41788&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41788&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41788&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41788&r=mysqlcfg