php.net |  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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
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
Description:
------------
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:
---------------
<?php

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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-25 18:31 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

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-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 20:01:36 2025 UTC