From:             PrzemekG_ at poczta dot onet dot pl
Operating system: GNU/Debian
PHP version:      5.2.6
PHP Bug Type:     Reproducible crash
Bug description:  defined() doesn't work properly.

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

-- 
Edit bug report at http://bugs.php.net/?id=46341&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=46341&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=46341&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=46341&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=46341&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=46341&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=46341&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=46341&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=46341&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=46341&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=46341&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=46341&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=46341&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=46341&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=46341&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=46341&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=46341&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=46341&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=46341&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=46341&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=46341&r=mysqlcfg

Reply via email to