]> granicus.if.org Git - php/commitdiff
- MFH: Synch
authorMarcus Boerger <helly@php.net>
Fri, 3 Nov 2006 18:58:41 +0000 (18:58 +0000)
committerMarcus Boerger <helly@php.net>
Fri, 3 Nov 2006 18:58:41 +0000 (18:58 +0000)
ext/spl/examples/directoryfilterdots.inc
ext/spl/internal/recursiveiteratoriterator.inc
ext/spl/php_spl.c
ext/spl/php_spl.h
ext/spl/tests/spl_autoload_009.phpt [new file with mode: 0755]

index fceeda2a23435d76e11856cf6caa5ade3d5e3895..26896e7cd522871bc1061f1680f4f6bffb4edcf8 100755 (executable)
@@ -4,7 +4,7 @@
  * @ingroup Examples
  * @brief class DirectoryFilterDots
  * @author  Marcus Boerger
- * @date    2003 - 2005
+ * @date    2003 - 2006
  *
  * SPL - Standard PHP Library
  */
@@ -12,7 +12,7 @@
 /** @ingroup Examples
  * @brief   A filtered DirectoryIterator
  * @author  Marcus Boerger
- * @version 1.1
+ * @version 1.2
  *
  * This Iteraotr takes a pathname from which it creates a DirectoryIterator
  * and makes it recursive. Further more it filters the entries '.' and '..'.
@@ -24,7 +24,7 @@ class DirectoryFilterDots extends RecursiveFilterIterator
         */
        function __construct($path)
        {
-               parent::__construct(new DirectoryIterator($path));
+               parent::__construct(new RecursiveDirectoryIterator($path));
        }
 
        /** @return whether the current entry is neither '.' nor '..'
index 716ab475ffad335de5abae7f8120a41fd7756af2..03c76394d10083bd157f1e604e2d6b645e77128c 100755 (executable)
@@ -217,7 +217,7 @@ class RecursiveIteratorIterator implements OuterIterator
                        if ($after_move)
                        {
                                if (($this->mode == self::SELF_FIRST && $this->callHasChildren())
-                                    $this->mode == self::LEAVES_ONLY)
+                               ||   $this->mode == self::LEAVES_ONLY)
                                $this->nextElement();
                        }
                        else
@@ -229,7 +229,9 @@ class RecursiveIteratorIterator implements OuterIterator
        
        /** Called when the next element is available
         */
-       function nextElement();
+       function nextElement()
+       {
+       }
 }
 
 ?>
\ No newline at end of file
index cbe176caaead803fffb9cb011b329d205bbc1c21..75ea892658cfc37105303bd0f5f87c15cd4f7a38 100755 (executable)
@@ -57,6 +57,7 @@ static PHP_GINIT_FUNCTION(spl)
 {
        spl_globals->autoload_extensions = NULL;
        spl_globals->autoload_functions  = NULL;
+       spl_globals->autoload_running    = 0;
 }
 /* }}} */
 
@@ -305,7 +306,7 @@ PHP_FUNCTION(spl_autoload)
        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);
        }
 } /* }}} */
@@ -361,6 +362,8 @@ PHP_FUNCTION(spl_autoload_call)
        }
 
        if (SPL_G(autoload_functions)) {
+               int l_autoload_running = SPL_G(autoload_running);
+               SPL_G(autoload_running) = 1;
                class_name_len = Z_STRLEN_P(class_name);
                lc_name = zend_str_tolower_dup(Z_STRVAL_P(class_name), class_name_len);
                zend_hash_internal_pointer_reset_ex(SPL_G(autoload_functions), &function_pos);
@@ -377,6 +380,7 @@ PHP_FUNCTION(spl_autoload_call)
                        zend_hash_move_forward_ex(SPL_G(autoload_functions), &function_pos);
                }
                efree(lc_name);
+               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);
index 4e8c9b3f7d3b2e4b2f76048555718845a903625f..fd8e5cb8b9cd9f0fdab8682e3f3131a2ddb0ee9e 100755 (executable)
@@ -58,6 +58,7 @@ PHP_MINFO_FUNCTION(spl);
 ZEND_BEGIN_MODULE_GLOBALS(spl)
        char *       autoload_extensions;
        HashTable *  autoload_functions;
+       int          autoload_running;
 ZEND_END_MODULE_GLOBALS(spl)
 
 #ifdef ZTS
diff --git a/ext/spl/tests/spl_autoload_009.phpt b/ext/spl/tests/spl_autoload_009.phpt
new file mode 100755 (executable)
index 0000000..c282bf4
--- /dev/null
@@ -0,0 +1,28 @@
+--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===