Fix bug #47534 (RecursiveDirectoryIterator::getChildren ignoring CURRENT_AS_PATHNAME)

This commit is contained in:
Etienne Kneuss 2009-05-09 21:05:18 +00:00
parent 5aa273d0ad
commit 9ca4884a71
2 changed files with 36 additions and 18 deletions

View File

@ -1386,28 +1386,32 @@ SPL_METHOD(RecursiveDirectoryIterator, getChildren)
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);
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);
spl_instantiate_arg_ex2(Z_OBJCE_P(getThis()), &return_value, 0, &zpath, &zflags TSRMLS_CC);
zval_dtor(&zpath);
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 = (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;
}
subdir->info_class = intern->info_class;
subdir->file_class = intern->file_class;
subdir->oth = intern->oth;
}
}
/* }}} */

View File

@ -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