From:             ryan dot brothers at gmail dot com
Operating system: Linux
PHP version:      5.5.0
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:Exception not catchable when exception thrown in autoload with 
a namespace

Description:
------------
In the following code, the exception is not caught.  In PHP 5.3, the
exception is caught, but in PHP 5.4 and PHP 5.5, the exception is not
caught.  The issue only occurs when the class is in a namespace.  If I
remove the namespace from the class, then the exception is caught.


Test script:
---------------
<?php
function __autoload($class)
{
    require('ns_test.php');

    throw new \Exception('abcd');
}

try
{
    \ns_test\test::go();
}
catch (Exception $e)
{
    echo 'caught';
    exit;
}

=================================================

ns_test.php:

<?php
namespace ns_test;

class test
{

}


Expected result:
----------------
caught

Actual result:
--------------
Warning: Uncaught exception 'Exception' with message 'abcd' in
/tmp/test.php:6
Stack trace:
#0 /tmp/test.php(11): __autoload('ns_test\test')
#1 {main}
  thrown in /tmp/test.php on line 6

Fatal error: Call to undefined method ns_test\test::go() in /tmp/test.php
on line 11


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

Reply via email to