colder          Sat May  9 21:05:18 2009 UTC

  Modified files:              
    /php-src/ext/spl/tests      bug47534.phpt 
    /php-src/ext/spl    spl_directory.c 
  Log:
  Fix bug #47534 (RecursiveDirectoryIterator::getChildren ignoring 
CURRENT_AS_PATHNAME)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/bug47534.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/spl/tests/bug47534.phpt
diff -u /dev/null php-src/ext/spl/tests/bug47534.phpt:1.2
--- /dev/null   Sat May  9 21:05:18 2009
+++ php-src/ext/spl/tests/bug47534.phpt Sat May  9 21:05:18 2009
@@ -0,0 +1,14 @@
+--TEST--
+SPL: RecursiveDirectoryIterator bug 47534
+--FILE--
+<?php
+$it1 = new RecursiveDirectoryIterator(dirname(__FILE__), 
FileSystemIterator::CURRENT_AS_PATHNAME);
+$it1->rewind();
+echo gettype($it1->current())."\n";
+
+$it2 = new RecursiveDirectoryIterator(dirname(__FILE__));
+$it2->rewind();
+echo gettype($it2->current())."\n";
+--EXPECT--
+unicode
+object
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.180&r2=1.181&diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.180 
php-src/ext/spl/spl_directory.c:1.181
--- php-src/ext/spl/spl_directory.c:1.180       Thu Mar 26 20:02:12 2009
+++ php-src/ext/spl/spl_directory.c     Sat May  9 21:05:18 2009
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_directory.c,v 1.180 2009/03/26 20:02:12 felipe Exp $ */
+/* $Id: spl_directory.c,v 1.181 2009/05/09 21:05:18 colder Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -1386,28 +1386,32 @@
        
        spl_filesystem_object_get_file_name(intern TSRMLS_CC);
 
-       INIT_PZVAL(&zflags);
-       INIT_PZVAL(&zpath);
-       ZVAL_LONG(&zflags, intern->flags);
-       ZVAL_ZSTRL(&zpath, intern->file_name_type, intern->file_name, 
intern->file_name_len, 1);
-
-       spl_instantiate_arg_ex2(Z_OBJCE_P(getThis()), &return_value, 0, &zpath, 
&zflags TSRMLS_CC);
-
-       zval_dtor(&zpath);
-
-       subdir = 
(spl_filesystem_object*)zend_object_store_get_object(return_value TSRMLS_CC);
-       if (subdir) {
-               if (intern->u.dir.sub_path.v && intern->u.dir.sub_path_len > 1) 
{
-                       subdir->u.dir.sub_path_type = 
intern->u.dir.sub_path_type;
-                       subdir->u.dir.sub_path_len = 
zspprintf(intern->u.dir.sub_path_type, &subdir->u.dir.sub_path, 0, "%R%c%s", 
intern->u.dir.sub_path_type, intern->u.dir.sub_path, slash, 
intern->u.dir.entry.d_name);
-               } else {
-                       subdir->u.dir.sub_path_len = 
strlen(intern->u.dir.entry.d_name);
-                       subdir->u.dir.sub_path_type = IS_STRING;
-                       subdir->u.dir.sub_path.s = 
estrndup(intern->u.dir.entry.d_name, subdir->u.dir.sub_path_len);
-               }
-               subdir->info_class = intern->info_class;
-               subdir->file_class = intern->file_class;
-               subdir->oth = intern->oth;
+       if (SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_CURRENT_AS_PATHNAME)) {
+               RETURN_ZSTRL(intern->file_name_type, intern->file_name, 
intern->file_name_len, 1);
+       } else {
+               INIT_PZVAL(&zflags);
+               INIT_PZVAL(&zpath);
+               ZVAL_LONG(&zflags, intern->flags);
+               ZVAL_ZSTRL(&zpath, intern->file_name_type, intern->file_name, 
intern->file_name_len, 1);
+
+               spl_instantiate_arg_ex2(Z_OBJCE_P(getThis()), &return_value, 0, 
&zpath, &zflags TSRMLS_CC);
+
+               zval_dtor(&zpath);
+
+               subdir = 
(spl_filesystem_object*)zend_object_store_get_object(return_value TSRMLS_CC);
+               if (subdir) {
+                       if (intern->u.dir.sub_path.v && 
intern->u.dir.sub_path_len > 1) {
+                               subdir->u.dir.sub_path_type = 
intern->u.dir.sub_path_type;
+                               subdir->u.dir.sub_path_len = 
zspprintf(intern->u.dir.sub_path_type, &subdir->u.dir.sub_path, 0, "%R%c%s", 
intern->u.dir.sub_path_type, intern->u.dir.sub_path, slash, 
intern->u.dir.entry.d_name);
+                       } else {
+                               subdir->u.dir.sub_path_len = 
strlen(intern->u.dir.entry.d_name);
+                               subdir->u.dir.sub_path_type = IS_STRING;
+                               subdir->u.dir.sub_path.s = 
estrndup(intern->u.dir.entry.d_name, subdir->u.dir.sub_path_len);
+                       }
+                       subdir->info_class = intern->info_class;
+                       subdir->file_class = intern->file_class;
+                       subdir->oth = intern->oth;
+               }
        }
 }
 /* }}} */



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

Reply via email to