cellog          Sat Sep 13 20:57:15 2008 UTC

  Modified files:              
    /php-src/ext/phar   util.c 
    /php-src/ext/phar/tests     bug46060.phpt 
  Log:
  MFB: fix Bug #46060: addEmptyDir() breaks
  
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/util.c?r1=1.63&r2=1.64&diff_format=u
Index: php-src/ext/phar/util.c
diff -u php-src/ext/phar/util.c:1.63 php-src/ext/phar/util.c:1.64
--- php-src/ext/phar/util.c:1.63        Thu Sep 11 03:33:10 2008
+++ php-src/ext/phar/util.c     Sat Sep 13 20:57:15 2008
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: util.c,v 1.63 2008/09/11 03:33:10 cellog Exp $ */
+/* $Id: util.c,v 1.64 2008/09/13 20:57:15 cellog Exp $ */
 
 #include "phar_internal.h"
 
@@ -785,13 +785,13 @@
        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 @@
 
        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)) {
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/bug46060.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/phar/tests/bug46060.phpt
diff -u /dev/null php-src/ext/phar/tests/bug46060.phpt:1.2
--- /dev/null   Sat Sep 13 20:57:15 2008
+++ php-src/ext/phar/tests/bug46060.phpt        Sat Sep 13 20:57:15 2008
@@ -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===



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

Reply via email to