helly           Tue Oct 31 23:18:00 2006 UTC

  Added files:                 
    /php-src/ext/spl/tests      spl_autoload_009.phpt 

  Modified files:              
    /php-src/ext/spl    php_spl.c php_spl.h 
  Log:
  - Fixed Bug #39313 spl_autoload triggers Fatal error
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.96&r2=1.97&diff_format=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.96 php-src/ext/spl/php_spl.c:1.97
--- php-src/ext/spl/php_spl.c:1.96      Thu Aug  3 14:53:51 2006
+++ php-src/ext/spl/php_spl.c   Tue Oct 31 23:18:00 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_spl.c,v 1.96 2006/08/03 14:53:51 iliaa Exp $ */
+/* $Id: php_spl.c,v 1.97 2006/10/31 23:18:00 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
        #include "config.h"
@@ -57,6 +57,7 @@
 {
        spl_globals->autoload_extensions = NULL;
        spl_globals->autoload_functions  = NULL;
+       spl_globals->autoload_running    = 0;
 }
 /* }}} */
 
@@ -303,7 +304,7 @@
        EG(active_op_array) = original_active_op_array;
        EG(function_state_ptr) = original_function_state_ptr;
 
-       if (!found) {
+       if (!found && !SPL_G(autoload_running)) {
                zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, 
"Class %s could not be loaded", class_name);
        }
 } /* }}} */
@@ -360,6 +361,8 @@
        }
 
        if (SPL_G(autoload_functions)) {
+               int l_autoload_running = SPL_G(autoload_running);
+               SPL_G(autoload_running) = 1;
                class_name_type = Z_TYPE_P(class_name);
                class_name_len = Z_UNILEN_P(class_name);
                lc_name = zend_u_str_tolower_dup(class_name_type, 
Z_UNIVAL_P(class_name), class_name_len);
@@ -378,6 +381,7 @@
                        zend_hash_move_forward_ex(SPL_G(autoload_functions), 
&function_pos);
                }
                efree(lc_name.v);
+               SPL_G(autoload_running) = l_autoload_running;
        } else {
                /* do not use or overwrite &EG(autoload_func) here */
                zend_call_method_with_1_params(NULL, NULL, NULL, 
"spl_autoload", NULL, class_name);
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.h?r1=1.18&r2=1.19&diff_format=u
Index: php-src/ext/spl/php_spl.h
diff -u php-src/ext/spl/php_spl.h:1.18 php-src/ext/spl/php_spl.h:1.19
--- php-src/ext/spl/php_spl.h:1.18      Sun Jan  1 13:09:54 2006
+++ php-src/ext/spl/php_spl.h   Tue Oct 31 23:18:00 2006
@@ -58,6 +58,7 @@
 ZEND_BEGIN_MODULE_GLOBALS(spl)
        char *       autoload_extensions;
        HashTable *  autoload_functions;
+       int          autoload_running;
 ZEND_END_MODULE_GLOBALS(spl)
 
 #ifdef ZTS

http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/spl_autoload_009.phpt?view=markup&rev=1.1
Index: php-src/ext/spl/tests/spl_autoload_009.phpt
+++ php-src/ext/spl/tests/spl_autoload_009.phpt
--TEST--
SPL: spl_autoload() and friends
--SKIPIF--
<?php if (!extension_loaded("spl")) print "skip"; ?>
--INI--
include_path=.
--FILE--
<?php

function my_autoload($name)
{
        require $name . '.class.inc';
        var_dump(class_exists($name));
}

spl_autoload_register("spl_autoload");
spl_autoload_register("my_autoload");

$obj = new testclass;

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
%stestclass.inc
%stestclass.class.inc
bool(true)
===DONE===

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to