Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:39041 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99901 invoked from network); 17 Jul 2008 09:50:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jul 2008 09:50:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=jochem@iamjochem.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=jochem@iamjochem.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain iamjochem.com from 194.109.193.121 cause and error) X-PHP-List-Original-Sender: jochem@iamjochem.com X-Host-Fingerprint: 194.109.193.121 mx1.moulin.nl Linux 2.6 Received: from [194.109.193.121] ([194.109.193.121:55975] helo=mx1.moulin.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id ED/4E-54589-3D51F784 for ; Thu, 17 Jul 2008 05:50:14 -0400 Received: from localhost (localhost [127.0.0.1]) by mx1.moulin.nl (Postfix) with ESMTP id 076B726D267 for ; Thu, 17 Jul 2008 11:50:09 +0200 (CEST) X-Virus-Scanned: amavisd-new at moulin.nl Received: from mx1.moulin.nl ([127.0.0.1]) by localhost (mx1.moulin.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eUQhmXqBSaGE for ; Thu, 17 Jul 2008 11:50:03 +0200 (CEST) Received: from [10.0.13.104] (ip129-15-211-87.adsl2.static.versatel.nl [87.211.15.129]) by mx1.moulin.nl (Postfix) with ESMTP id E01AB26D1E7 for ; Thu, 17 Jul 2008 11:50:02 +0200 (CEST) Message-ID: <487F15CA.7000608@iamjochem.com> Date: Thu, 17 Jul 2008 11:50:02 +0200 User-Agent: Thunderbird 2.0.0.14 (Macintosh/20080421) MIME-Version: 1.0 To: php internals X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: autoload somewhat broken? or do the docs need more info? From: jochem@iamjochem.com (Jochem Maas) hello people, I believe there is something wrong (or inconsitent) with the way __autoload() behaves. at the least the current docs don't reflect what I'm seeing. 1. the docs state: "Exceptions thrown in __autoload function cannot be caught in the catch block and results in a fatal error." this is not exactly true, I can catch exception throw from __autoload() IF __autoload() was triggered via call_user_func*(), class_exists() & is_callable() 2. if a user error handler is set with set_error_handler() any errors (at least upto and including E_WARNING) that occur in a function that triggers (e.g. call_user_func()) __autoload() will not be given to the error handler function (it never recieves a call) if the __autoload() it triggered throws an exception (that is not caught inside __autoload(). 3. I suspect that point 2. is the reason that in some real-world situations even Fatal Errors are not logged at (to screen or file, regardless of error_reporting/display_error settings), resulting in a blank screen and no idea as to the cause ... I have seen this happen repeatedly on different versions/machines/etc since php5 was in beta ... I have still not be able to reproduce the vanishing Fatal Errors in a simple test script ... that said on all occasions where nothing was logged for such Fatal Errors (which in my case are always the result of a class that cannot be found) I could run the same script via a debugger which then always did show the Fatal Error message ... why would running the script via a debugger show [Fatal Error] output in the browser window where as running the script normally [in the browser] results in no output whatsoever? Anyway I don't really know if anything is wrong, whether the docs need updating, or whether someone should really look at the situation. I have written a little 'test suite'[1] with which one can observe __autoload() behaviour in various configurations ... it comes with little shell script called 'runtests.sh': $ ./runtests.sh usage: ./runtests.sh [--set-err-handler] [--display-errors] [--gen-class] [--no-autoload|--no-throw [--spl-autoload]] must be one of: new new2 static class_exists call_user_func call_user_func_array is_callable OR all --set-err-handler = define a user function to trap php errors. --display-errors = sets php ini setting display_errors on. --no-autoload = skip autoloader function definition. --no-throw = tell the autoloader not to throw the exception. --spl-autoload = use spl_autoload_register() instead of __autoload() --recurse-autoload = trigger __autoload from within __autoload --gen-class = to have autoload auto-generate the class (exception will still be thrown) classes will have __construct(), __call() and __callstatic() methods 1. you may export an environment variable $PHP_TEST_BIN to control which php binary used to run the tests 2. errors logs are recreated on each run for each in ./logs/.log rgds, Jochem [1] http://iamjochem.com/autoload_behaviour_tests.zip