mirror of
https://github.com/php/php-src.git
synced 2026-03-27 01:32:22 +01:00
fix Bug #46060: addEmptyDir() breaks
This commit is contained in:
30
ext/phar/tests/bug46060.phpt
Normal file
30
ext/phar/tests/bug46060.phpt
Normal file
@@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
Phar: Bug #46060: addEmptyDir() breaks
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("phar")) die("skip"); ?>
|
||||
<?php if (getenv('SKIP_SLOW_TESTS')) die('skip'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.tar';
|
||||
$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.tar';
|
||||
|
||||
$phar = new PharData($fname);
|
||||
$phar->addEmptyDir('blah/');
|
||||
$phar->addFromString('test/', '');
|
||||
|
||||
copy($fname, $fname2);
|
||||
$phar = new PharData($fname2);
|
||||
|
||||
var_dump($phar['blah']->isDir(), $phar['test']->isDir());
|
||||
?>
|
||||
===DONE===
|
||||
--CLEAN--
|
||||
<?php
|
||||
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar');
|
||||
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.tar');
|
||||
__HALT_COMPILER();
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(false)
|
||||
===DONE===
|
||||
@@ -785,13 +785,13 @@ phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char
|
||||
if (allow_dir == 2) {
|
||||
etemp.is_dir = 1;
|
||||
etemp.flags = etemp.old_flags = PHAR_ENT_PERM_DEF_DIR;
|
||||
if (is_dir) {
|
||||
etemp.filename_len--; /* strip trailing / */
|
||||
path_len--;
|
||||
}
|
||||
} else {
|
||||
etemp.flags = etemp.old_flags = PHAR_ENT_PERM_DEF_FILE;
|
||||
}
|
||||
if (is_dir) {
|
||||
etemp.filename_len--; /* strip trailing / */
|
||||
path_len--;
|
||||
}
|
||||
|
||||
phar_add_virtual_dirs(phar, path, path_len TSRMLS_CC);
|
||||
etemp.is_modified = 1;
|
||||
@@ -803,7 +803,7 @@ phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char
|
||||
|
||||
if (phar->is_tar) {
|
||||
etemp.is_tar = phar->is_tar;
|
||||
etemp.tar_type = TAR_FILE;
|
||||
etemp.tar_type = etemp.is_dir ? TAR_DIR : TAR_FILE;
|
||||
}
|
||||
|
||||
if (FAILURE == zend_hash_add(&phar->manifest, etemp.filename, path_len, (void*)&etemp, sizeof(phar_entry_info), (void **) &entry)) {
|
||||
|
||||
Reference in New Issue
Block a user