|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39257 preg_replace_callback swallows exceptions
Submitted: 2006-10-25 17:52 UTC Modified: 2006-12-08 03:23 UTC
From: php at theos dot me dot uk Assigned:
Status: Closed Package: PCRE related
PHP Version: 5.1.6 OS: Debian Sid
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: php at theos dot me dot uk
New email:
PHP Version: OS:


 [2006-10-25 17:52 UTC] php at theos dot me dot uk
If a function called by preg_replace_callback throws an 
exception this exception is not propagated up to the 
function which called preg_replace_callback. Instead a PHP 
error is produced. This error contains no information about 
what the problem was or where it occurred.

Reproduce code:

function thrower() {
  throw new Exception("Hello");

try {
  $b = preg_replace_callback('/./', 'thrower', 'a');
} catch ( Exception $e ) {
  echo 'Yay, exception!';


Expected result:
code to output

Yay, exception!

Actual result:
Warning: preg_replace_callback(): Unable to call custom 
replacement function on line 13


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-25 18:31 UTC]
Please try using this CVS snapshot:
For Windows:

Cannot reproduce.
 [2006-11-02 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2006-12-08 03:23 UTC] php at theos dot me dot uk
Works in 5.2
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Oct 18 21:03:39 2021 UTC