|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-08-28 20:38 UTC] spam2 at rhsoft dot net
[2017-08-29 13:54 UTC] cmb@php.net
-Status: Open
+Status: Duplicate
-Assigned To:
+Assigned To: cmb
[2017-08-29 13:54 UTC] cmb@php.net
[2017-08-30 00:18 UTC] php at richardneill dot org
[2017-08-30 06:14 UTC] spam2 at rhsoft dot net
[2017-08-30 12:14 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 22 04:00:01 2025 UTC |
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)