php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45656 spl_autoload cannot handle exceptions
Submitted: 2008-07-29 15:30 UTC Modified: 2008-09-15 10:21 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: php at benjaminschulz dot com Assigned: colder (profile)
Status: Closed Package: SPL related
PHP Version: 5.3CVS-2008-07-29 (CVS) OS: *
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 benjaminschulz dot com
New email:
PHP Version: OS:

 

 [2008-07-29 15:30 UTC] php at benjaminschulz dot com
Description:
------------
If spl_autoload() is triggered by class_exists() it is able to handle occuring exceptions but if it is triggered through "new .." then exceptions are silently ignored.
Attached is an adapted copy of spl_autoload_012.phpt.

Reproduce code:
---------------
--TEST--
SPL: spl_autoload() capturing multiple Exceptions in __autoload
--FILE--
<?php

function autoload_first($name)
{
  echo __METHOD__ . "\n";
  throw new Exception('first');
}

function autoload_second($name)
{
  echo __METHOD__ . "\n";
  throw new Exception('second');
}

spl_autoload_register('autoload_first');
spl_autoload_register('autoload_second');

new ThisClassDoesNotExist;

?>
===DONE===
--EXPECTF--
autoload_first
autoload_second

Fatal error: Uncaught exception 'Exception' with message 'first' in %sspl_autoload_013.php:%d
Stack trace:
#0 [internal function]: autoload_first('ThisClassDoesNo...')
#1 [internal function]: spl_autoload_call('ThisClassDoesNo...')
#2 %sspl_autoload_013.php(%d): class_exists('ThisClassDoesNo...')
#3 {main}

Next exception 'Exception' with message 'second' in %sspl_autoload_013.php:%d
Stack trace:
#0 [internal function]: autoload_second('ThisClassDoesNo...')
#1 [internal function]: spl_autoload_call('ThisClassDoesNo...')
#2 %sspl_autoload_013.php(%d): class_exists('ThisClassDoesNo...')
#3 {main}
  thrown in %sspl_autoload_013.php on line %d


Actual result:
--------------
autoload_first
autoload_second
PHP Fatal error:  Class 'ThisClassDoesNotExist' not found in ... on line 0

Fatal error: Class 'ThisClassDoesNotExist' not found in ... on line 0

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-15 10:21 UTC] colder@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 04:01:28 2024 UTC