Edit report at http://bugs.php.net/bug.php?id=51741&edit=1
ID: 51741 Updated by: bj...@php.net Reported by: jordi dot salvat dot i dot alabart at gmail dot com Summary: preg_match returns zero if it hits backtracking limit Status: Bogus Type: Bug Package: PCRE related Operating System: Ubuntu PHP Version: 5.3SVN-2010-05-04 (SVN) New Comment: docs.php.net is a development mirror, not an official mirror. See http://php.net/mirrors That bug has however been fixed, thanks for the report. Previous Comments: ------------------------------------------------------------------------ [2010-05-12 11:15:43] jordi dot salvat dot i dot alabart at gmail dot com So this is a documentation error. I've tried to add a comment to http://docs.php.net/manual/en/function.preg-match.php, but I got this: << Warning: include(/home/local/Web/sites/docs.php.net/manual/include/spam-func.php) [function.include]: failed to open stream: No such file or directory in /home/local/Web/sites/docs.php.net/manual/add-note.php on line 9 Warning: include() [function.include]: Failed opening '/home/local/Web/sites/docs.php.net/manual/include/spam-func.php' for inclusion (include_path='.:/local/php/lib/php') in /home/local/Web/sites/docs.php.net/manual/add-note.php on line 9 Fatal error: Call to undefined function kill_spammer() in /home/local/Web/sites/docs.php.net/manual/add-note.php on line 10 >> I should have stuck to Java. ------------------------------------------------------------------------ [2010-05-12 09:52:45] m...@php.net Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. > Note that pcretest does report an error in this same case As can be queried with preg_last_error(). ------------------------------------------------------------------------ [2010-05-04 20:32:41] jordi dot salvat dot i dot alabart at gmail dot com Description: ------------ According to the documentation, pcre_match should return FALSE on error: >From http://docs.php.net/manual/en/function.preg-match.php : << Return Values preg_match() returns the number of times pattern matches. That will be either 0 times (no match) or 1 time because preg_match() will stop searching after the first match. preg_match_all() on the contrary will continue until it reaches the end of subject. preg_match() returns FALSE if an error occurred. >> Instead, it returns 0 (integer zero) -- see Felipe's comment on http://bugs.php.net/bug.php?id=51663&edit=2 for a check. Note that pcretest does report an error in this same case: $ pcretest PCRE version 7.8 2008-09-05 re> /(.+)+:/ data> \q10a:bbb Error -8 data> Test script: --------------- <? ini_set('pcre.backtrack_limit', 10); print_r( preg_match('/(.+)+:/','a:bbb') === FALSE ? 'pass' : 'fail' ); Expected result: ---------------- pass Actual result: -------------- fail ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=51741&edit=1