From: Greg Beaver Date: Tue, 24 Jun 2008 01:11:27 +0000 (+0000) Subject: fix several issues: X-Git-Tag: php-5.3.0alpha1~626 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8bf72978b35ed58a938719ff6f52f1cd3d6d1c14;p=php fix several issues: 1) segfault in phar_buildfromdirectoryiterator8.phpt 2) tests failing because SKIPDOTS is default on 64 bit, not on 32 3) Marcus, you really need to add SKIPDOTS as a class constant, so we don't have to use 0x00001000 --- diff --git a/ext/phar/phar.phar b/ext/phar/phar.phar index 8d0ec2fea5..e299feb7d6 100755 Binary files a/ext/phar/phar.phar and b/ext/phar/phar.phar differ diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index ffd42bdb5d..6e7b3e0bc4 100755 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1134,7 +1134,7 @@ PHP_METHOD(Phar, __construct) #else char *fname, *alias = NULL, *error, *arch = NULL, *entry = NULL, *save_fname; int fname_len, alias_len = 0, arch_len, entry_len, is_data; - long flags = 0, format = 0; + long flags = SPL_FILE_DIR_SKIPDOTS, format = 0; phar_archive_object *phar_obj; phar_archive_data *phar_data; zval *zobj = getThis(), arg1, arg2; @@ -1237,15 +1237,10 @@ PHP_METHOD(Phar, __construct) INIT_PZVAL(&arg1); ZVAL_STRINGL(&arg1, fname, fname_len, 0); - if (ZEND_NUM_ARGS() > 1) { - INIT_PZVAL(&arg2); - ZVAL_LONG(&arg2, flags); - zend_call_method_with_2_params(&zobj, Z_OBJCE_P(zobj), - &spl_ce_RecursiveDirectoryIterator->constructor, "__construct", NULL, &arg1, &arg2); - } else { - zend_call_method_with_1_params(&zobj, Z_OBJCE_P(zobj), - &spl_ce_RecursiveDirectoryIterator->constructor, "__construct", NULL, &arg1); - } + INIT_PZVAL(&arg2); + ZVAL_LONG(&arg2, flags); + zend_call_method_with_2_params(&zobj, Z_OBJCE_P(zobj), + &spl_ce_RecursiveDirectoryIterator->constructor, "__construct", NULL, &arg1, &arg2); if (!phar_data->is_persistent) { phar_obj->arc.archive->is_data = is_data; @@ -1621,6 +1616,7 @@ after_open_fp: data->internal_file->fp = NULL; data->internal_file->fp_type = PHAR_UFP; data->internal_file->offset_abs = data->internal_file->offset = php_stream_tell(p_obj->fp); + data->fp = NULL; contents_len = php_stream_copy_to_stream(fp, p_obj->fp, PHP_STREAM_COPY_ALL); data->internal_file->uncompressed_filesize = data->internal_file->compressed_filesize = php_stream_tell(p_obj->fp) - data->internal_file->offset; @@ -1681,9 +1677,11 @@ PHP_METHOD(Phar, buildFromDirectory) INIT_PZVAL(&arg); ZVAL_STRINGL(&arg, dir, dir_len, 0); + INIT_PZVAL(&arg2); + ZVAL_LONG(&arg2, SPL_FILE_DIR_SKIPDOTS); - zend_call_method_with_1_params(&iter, spl_ce_RecursiveDirectoryIterator, - &spl_ce_RecursiveDirectoryIterator->constructor, "__construct", NULL, &arg); + zend_call_method_with_2_params(&iter, spl_ce_RecursiveDirectoryIterator, + &spl_ce_RecursiveDirectoryIterator->constructor, "__construct", NULL, &arg, &arg2); if (EG(exception)) { zval_ptr_dtor(&iter); diff --git a/ext/phar/tests/phar_buildfromiterator8.phpt b/ext/phar/tests/phar_buildfromiterator8.phpt index d382b82ee0..bb1b780d75 100644 --- a/ext/phar/tests/phar_buildfromiterator8.phpt +++ b/ext/phar/tests/phar_buildfromiterator8.phpt @@ -3,7 +3,6 @@ Phar::buildFromIterator() RegexIterator(DirectoryIterator), SplFileInfo as curre --SKIPIF-- --INI-- -phar.require_hash=0 phar.readonly=0 --FILE-- addEmptyDir('one/level'); $a->extractTo(dirname(__FILE__) . '/extract', 'mount'); $a->extractTo(dirname(__FILE__) . '/extract'); $out = array(); -foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__) . '/extract'), RecursiveIteratorIterator::CHILD_FIRST) as $p => $b) { +foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__) . '/extract', 0x00001000), RecursiveIteratorIterator::CHILD_FIRST) as $p => $b) { $out[] = $p; } sort($out); diff --git a/ext/phar/tests/phar_extract2.phpt b/ext/phar/tests/phar_extract2.phpt index 64b8a74588..180d6ff4a5 100644 --- a/ext/phar/tests/phar_extract2.phpt +++ b/ext/phar/tests/phar_extract2.phpt @@ -23,7 +23,7 @@ $phar->extractTo(dirname(__FILE__) . '/extract', 'mount'); $phar->extractTo(dirname(__FILE__) . '/extract'); $out = array(); -foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__) . '/extract'), RecursiveIteratorIterator::CHILD_FIRST) as $path => $file) { +foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__) . '/extract', 0x00001000), RecursiveIteratorIterator::CHILD_FIRST) as $path => $file) { $extracted[] = $path; }