|  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
23 + 23 = ?
Subscribe to this entry?

 [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: Sun Oct 17 10:03:37 2021 UTC