php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49296 spl_autoload throws an exception instead of fatal error
Submitted: 2009-08-19 13:54 UTC Modified: 2009-08-20 10:26 UTC
From: christopheb156 at hotmail dot com Assigned:
Status: Not a bug Package: SPL related
PHP Version: 5.2SVN-2009-08-19 (snap) OS: xp
Private report: No CVE-ID: None
 [2009-08-19 13:54 UTC] christopheb156 at hotmail dot com
Description:
------------
spl_autoload should produce a fatal error when called indirectly, internal errors should generate E_ERROR, however in spl_autoload_001.phpt a call to class_exists throws an exception.



Reproduce code:
---------------
<?php

spl_autoload_register();

try {

  var_dump(class_exists("TestClass", true));

} catch(Exception $e) {

  echo $e->getMessage() . "\n";

}

?>

Expected result:
----------------
Fatal Error....

Actual result:
--------------
Class TestClass could not be loaded

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-19 14:28 UTC] colder@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

We're dealing with OOP here, exceptions feels like the natural way to report/handle such errors.
 [2009-08-20 10:26 UTC] christopheb156 at hotmail dot com
aah okay but was wondering why in phpt bug38325.phpt it returns a fatal error, looking at the source it says:

/* For internal errors, we generate E_ERROR, for direct calls an *exception is thrown. The "scope" is determined by an opcode, if it is *ZEND_FETCH_CLASS we know function was called indirectly by the Zend *engine.
*/

so class_exist would result in an indirect call to spl_autoload?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 13:01:32 2024 UTC