#48556 [Opn->Fbk]: throwing exceptions from __autoload()

From: Date: Mon, 05 Oct 2009 09:47:57 +0000
Subject: #48556 [Opn->Fbk]: throwing exceptions from __autoload()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-143269@lists.php.net to get a copy of this message
ID: 48556 Updated by: colder@php.net -Summary: eval() won't execute from __autoload() Reported By: neemah86 at gmail dot com -Status: Open +Status: Feedback -Bug Type: SPL related +Bug Type: Scripting Engine problem Operating System: Debian Lenny (FreeBSD 7.0 also) PHP Version: 5.2.9 New Comment: 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? Previous Comments: ------------------------------------------------------------------------ [2009-06-15 12:05:43] neemah86 at gmail dot com Also forgot to mention, that fatal error is - "class 'someClass' not found in ... " ------------------------------------------------------------------------ [2009-06-15 10:30:59] neemah86 at gmail dot com class definition is: __autoload_failed($className, $message) ------------------------------------------------------------------------ [2009-06-15 10:28:06] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48556&edit=1

« previous php.bugs (#143269) next »