|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-10-19 18:25 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 10:00:01 2025 UTC |
Description: ------------ People use defined() to check if a constant is defined so they can later use constant() without any warning or error. I found these bugs: 1. defined() doesn't forward exceptions 2. defined() try to load class from an invalid constant name (false:::::) 3. produce invalid error line white raising an error if autoloader thrown an exception. There should be a $autoload param like in class_exists() and interface_exists(). Reproduce code: --------------- <? function autoloader($class) { throw new Exception(); // line 3 } spl_autoload_register('autoloader'); function foo() { defined('false:::::::'); // line 9 $a = 10; $b = 11; } // line 12 foo(); // line 14 ?> Expected result: ---------------- From PHP 5.1.2: Fatal error: Uncaught exception 'Exception' in /root/x.php:3 Stack trace: #0 [internal function]: autoloader('false') #1 [internal function]: spl_autoload_call('false') #2 /root/x.php(9): defined('false:::::::') #3 /root/x.php(14): foo() #4 {main} thrown in /root/x.php on line 3 Actual result: -------------- From PHP 5.2.6: Fatal error: Class 'false' not found in /root/workspace.appserv/XAS/bugTest.php on line 12