]> granicus.if.org Git - php/commitdiff
fix edge case where a new phar is created via mkdir(), add to dir.phpt test
authorGreg Beaver <cellog@php.net>
Mon, 14 Apr 2008 15:21:41 +0000 (15:21 +0000)
committerGreg Beaver <cellog@php.net>
Mon, 14 Apr 2008 15:21:41 +0000 (15:21 +0000)
ext/phar/phar.c
ext/phar/tests/dir.phpt
ext/phar/util.c

index 85f62b8e176e978ceaba970b19c7fffb318bc0f2..8760e5dbbdae7ccadc39f829541414269a07d0ab 100644 (file)
@@ -2045,7 +2045,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
                offset += 4 + entry->filename_len + sizeof(entry_buffer) + entry->metadata_str.len + (entry->is_dir ? 1 : 0);
 
                /* compress and rehash as necessary */
-               if (oldfile && !entry->is_modified) {
+               if ((oldfile && !entry->is_modified) || entry->is_dir) {
                        continue;
                }
                if (!phar_get_efp(entry TSRMLS_CC)) {
@@ -2302,7 +2302,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
                if (zend_hash_get_current_data(&phar->manifest, (void **)&entry) == FAILURE) {
                        continue;
                }
-               if (entry->is_deleted) {
+               if (entry->is_deleted || entry->is_dir) {
                        continue;
                }
                if (entry->cfp) {
index 233e28c6820d640a291874f773dafc54112313a7..2aa8880e3eaf552964b01b5e66c8aa72b5b90cc9 100644 (file)
@@ -31,11 +31,13 @@ var_dump(file_exists($pname3 . '/another/dir/'));
 ini_set('phar.readonly', 1);
 mkdir($pname . '/fails');
 ini_set('phar.readonly', 0);
-mkdir('phar://oops.phar/fails');
+// create new phar by mkdir
+mkdir('phar://' . dirname(__FILE__) . '/ok.phar/fails');
 ?>
 ===DONE===
 --CLEAN--
 <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/ok.phar'); ?>
 <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php'); ?>
 <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.php'); ?>
 --EXPECTF--
index 0791bb0ebbc9a6cc6d71913288ef2a4645fd896e..f07000df87637c65309fc6943174aaf2f801e350 100644 (file)
@@ -471,6 +471,7 @@ int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char
        if (entry->is_dir) {
                *ret = (phar_entry_data *) emalloc(sizeof(phar_entry_data));
                (*ret)->position = 0;
+               (*ret)->fp = NULL;
                (*ret)->phar = phar;
                (*ret)->for_write = for_write;
                (*ret)->internal_file = entry;