Edit report at https://bugs.php.net/bug.php?id=75133&edit=1
ID: 75133
Comment by: spam2 at rhsoft dot net
Reported by: php at richardneill dot org
Summary: When preg_replace fails, please write to error_log
Status: Open
Type: Feature/Change Request
Package: PCRE related
Operating System: Linux
PHP Version: 7.0.22
Block user comment: N
Private report: N
New Comment:
there is no reason to spit into the error log just because you don't properly check return
values where you can calk error_log() at your own
proper production servers have E_ALL enabled and if something spits into my logs or enforce using @
would lead to a bug report to fix that broken behavior
Previous Comments:
------------------------------------------------------------------------
[2017-08-28 18:33:45] php at richardneill dot org
Description:
------------
It's very rare that preg_replace() fails (i.e. returns null). But when it happens, it's
really unexpected, and therefore particularly hard to debug. All the normal tools show nothing
helpful.
Can I request that whenever preg_replace (and preg_replace_callback) return a null, that
preg_last_error() is printed to the error_log, at least at E_NOTICE?
Test script:
---------------
It may be helpful to give an example. This code generates a
PREG_JIT_STACKLIMIT_ERROR, with only ~ 5kB of data in $contents
$contents =
preg_replace_callback
('/^\s*\%LOOP_(\d+|(ITR)(\d))\s*\n((((?!%LOOP_ITR).)*\n)*)\s*\%END_LOOP\s*\n/mU',
'repeat_n_times', $contents);
Expected result:
----------------
It shouldn't be possible to write a 1-line regexp which hits resource-limits on one screenful
of text. But if we do, it would be really helpful if there were some error message in the log files.
Actual result:
--------------
PHP Notice: preg_replace experienced a PREG_JIT_STACKLIMIT_ERROR in (filename) on (line_number)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75133&edit=1