Bug #60182 [NEW]: Implicit call to spl_autoload_call() does not throw exceptions

From: Date: Mon, 31 Oct 2011 22:41:24 +0000
Subject: Bug #60182 [NEW]: Implicit call to spl_autoload_call() does not throw exceptions
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-164744@lists.php.net to get a copy of this message
From:             
Operating system: Debian GNU/Linux
PHP version:      5.3.8
Package:          SPL related
Bug Type:         Bug
Bug description:Implicit call to spl_autoload_call() does not throw exceptions

Description:
------------
Exceptions thrown from custom autoload function are not thrown outside the

spl_autoload_call() function when it is implicitly called on expressions
like 
'A::someMethod();' and '$b = A::CONSTANT;', i.e. when accessing static
methods 
and constants of the class.

Test script:
---------------
<?php

function autoload($class)
{
    debug_print_backtrace();
    throw new Exception('Test message');
}

spl_autoload_register('autoload');

try {
    A::$someVariable;
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}

try {
    A::someMethod();
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}

Expected result:
----------------
#0  autoload(A)
#1  spl_autoload_call(A) called at [/tmp/1.php:12]
Test message
#0  autoload(A)
#1  spl_autoload_call(A) called at [/tmp/1.php:18]
Test message

Actual result:
--------------
#0  autoload(A)
#1  spl_autoload_call(A) called at [/tmp/1.php:12]
Test message
#0  autoload(A)
#1  spl_autoload_call(A) called at [/tmp/1.php:18]
PHP Fatal error:  Class 'A' not found in /tmp/1.php on line 18
PHP Stack trace:
PHP   1. {main}() /tmp/1.php:0

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



Thread (3 messages)

« previous php.bugs (#164744) next »