php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48556 throwing exceptions from __autoload()
Submitted: 2009-06-15 10:28 UTC Modified: 2009-10-13 01:00 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: neemah86 at gmail dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5.2.9 OS: Debian Lenny (FreeBSD 7.0 also)
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-06-15 10:28 UTC] neemah86 at gmail dot com
Description:
------------
Hi.
Trying to throw exception from __autoload() by evaluating code (eval()).

In earlier version of php5 that would give me exception that i need. Now it gives me fatal ignoring eval statement. 

Reproduce code:
---------------
function __autoload_failed() {
    eval(
        'if (!class_exists("ClassNotFoundException", false)) { '
        .'final class ClassNotFoundException extends Exception {/*_*/} }'
        .'throw new ClassNotFoundException("'.$classname.': '.$message.'");'
    );
}

function __autoload($className) {
    // insert your logic here
    __autoload_failed($className, 'not found'); // in any place, actually
}

Expected result:
----------------
ClassNotFoundException thrown

Actual result:
--------------
Fatal error

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-15 10:30 UTC] neemah86 at gmail dot com
class definition is:
__autoload_failed($className, $message)
 [2009-06-15 12:05 UTC] neemah86 at gmail dot com
Also forgot to mention, that fatal error is - "class 'someClass' not found in ... "
 [2009-10-05 09:47 UTC] colder@php.net
The problem is not eval, it's about exceptions that cannot be thrown from autoload since the fatal occurs "first".

It works fine in 5_3, though.

What is the PHP5 version that threw the exception?
 [2009-10-13 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".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 05:01:31 2024 UTC