pajoye          Wed Nov 12 11:59:26 2008 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/zip/tests      bug14962.phpt bug38943.inc bug38943_2.phpt 

  Modified files:              
    /php-src/ext/zip    php_zip.c php_zip.h 
    /php-src/ext/zip/tests      bug38943.phpt bug7658.phpt oo_delete.phpt 
  Log:
  - MFH:
   - #14962, makes extractTo 2nd argument really optional
   - replace ZEND_ENGINE_2_1 by PHP_ZIP_USE_OO
   - sync tests
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.44&r2=1.1.2.45&diff_format=u
Index: php-src/ext/zip/php_zip.c
diff -u php-src/ext/zip/php_zip.c:1.1.2.44 php-src/ext/zip/php_zip.c:1.1.2.45
--- php-src/ext/zip/php_zip.c:1.1.2.44  Thu Oct 23 16:13:50 2008
+++ php-src/ext/zip/php_zip.c   Wed Nov 12 11:59:26 2008
@@ -12,11 +12,11 @@
   | obtain it through the world-wide-web, please send a note to          |
   | [EMAIL PROTECTED] so we can mail you a copy immediately.               |
   +----------------------------------------------------------------------+
-  | Author: Piere-Alain Joye <[EMAIL PROTECTED]                             |
+  | Author: Piere-Alain Joye <[EMAIL PROTECTED]>                            |
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_zip.c,v 1.1.2.44 2008/10/23 16:13:50 pajoye Exp $ */
+/* $Id: php_zip.c,v 1.1.2.45 2008/11/12 11:59:26 pajoye Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -473,7 +473,7 @@
 /* }}} */
 
 /* {{{ ZE2 OO definitions */
-#ifdef ZEND_ENGINE_2_1
+#ifdef PHP_ZIP_USE_OO 
 static zend_class_entry *zip_class_entry;
 static zend_object_handlers zip_object_handlers;
 
@@ -493,7 +493,7 @@
 #endif
 /* }}} */
 
-#ifdef ZEND_ENGINE_2_1
+#ifdef PHP_ZIP_USE_OO 
 static void php_zip_register_prop_handler(HashTable *prop_handler, char *name, 
zip_read_int_t read_int_func, zip_read_const_char_t read_char_func, 
zip_read_const_char_from_ze_t read_char_from_obj_func, int rettype TSRMLS_DC) 
/* {{{ */
 {
        zip_prop_handler hnd;
@@ -1137,7 +1137,7 @@
 }
 /* }}} */
 
-#ifdef ZEND_ENGINE_2_1
+#ifdef PHP_ZIP_USE_OO 
 /* {{{ proto mixed ZipArchive::open(string source [, int flags])
 Create new zip using source uri for output, return TRUE on success or the 
error code */
 static ZIPARCHIVE_METHOD(open)
@@ -1975,7 +1975,7 @@
        }
 
        ZIP_FROM_OBJECT(intern, this);
-       if (zval_files) {
+       if (zval_files && (Z_TYPE_P(zval_files) != IS_NULL)) {
                switch (Z_TYPE_P(zval_files)) {
                        case IS_STRING:
                                if (!php_zip_extract_file(intern, pathto, 
Z_STRVAL_P(zval_files), Z_STRLEN_P(zval_files) TSRMLS_CC)) {
@@ -2276,7 +2276,7 @@
        php_info_print_table_start();
 
        php_info_print_table_row(2, "Zip", "enabled");
-       php_info_print_table_row(2, "Extension Version","$Id: php_zip.c,v 
1.1.2.44 2008/10/23 16:13:50 pajoye Exp $");
+       php_info_print_table_row(2, "Extension Version","$Id: php_zip.c,v 
1.1.2.45 2008/11/12 11:59:26 pajoye Exp $");
        php_info_print_table_row(2, "Zip version", PHP_ZIP_VERSION_STRING);
        php_info_print_table_row(2, "Libzip version", "0.9.0");
 
http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.h?r1=1.10.2.6&r2=1.10.2.7&diff_format=u
Index: php-src/ext/zip/php_zip.h
diff -u php-src/ext/zip/php_zip.h:1.10.2.6 php-src/ext/zip/php_zip.h:1.10.2.7
--- php-src/ext/zip/php_zip.h:1.10.2.6  Thu Oct 23 16:13:50 2008
+++ php-src/ext/zip/php_zip.h   Wed Nov 12 11:59:26 2008
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_zip.h,v 1.10.2.6 2008/10/23 16:13:50 pajoye Exp $ */
+/* $Id: php_zip.h,v 1.10.2.7 2008/11/12 11:59:26 pajoye Exp $ */
 
 #ifndef PHP_ZIP_H
 #define PHP_ZIP_H
@@ -32,10 +32,8 @@
 
 #define PHP_ZIP_VERSION_STRING "1.8.11"
 
-#ifndef ZEND_ENGINE_2_1
-# if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 0) || PHP_MAJOR_VERSION == 
6
-#  define ZEND_ENGINE_2_1
-# endif
+#if ((PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 2) || PHP_MAJOR_VERSION 
>= 6)
+# define PHP_ZIP_USE_OO 1
 #endif
 
 #ifndef  Z_SET_REFCOUNT_P
@@ -68,7 +66,7 @@
        struct zip_stat sb;
 } zip_read_rsrc;
 
-#ifdef ZEND_ENGINE_2_1
+#ifdef PHP_ZIP_USE_OO 
 #define ZIPARCHIVE_ME(name, arg_info, flags)   ZEND_FENTRY(name, c_ziparchive_ 
##name, arg_info, flags)
 #define ZIPARCHIVE_METHOD(name)        ZEND_NAMED_FUNCTION(c_ziparchive_##name)
 
http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/bug38943.phpt?r1=1.1.2.2&r2=1.1.2.3&diff_format=u
Index: php-src/ext/zip/tests/bug38943.phpt
diff -u php-src/ext/zip/tests/bug38943.phpt:1.1.2.2 
php-src/ext/zip/tests/bug38943.phpt:1.1.2.3
--- php-src/ext/zip/tests/bug38943.phpt:1.1.2.2 Mon Oct  9 16:02:34 2006
+++ php-src/ext/zip/tests/bug38943.phpt Wed Nov 12 11:59:26 2008
@@ -1,26 +1,14 @@
 --TEST--
-#38943, properties in extended class cannot be set
+#38943, properties in extended class cannot be set (< 5.3)
 --SKIPIF--
 <?php
-/* $Id: bug38943.phpt,v 1.1.2.2 2006/10/09 16:02:34 bjori Exp $ */
+/* $Id: bug38943.phpt,v 1.1.2.3 2008/11/12 11:59:26 pajoye Exp $ */
 if(!extension_loaded('zip')) die('skip');
+if (!defined('PHP_VERSION_MAJOR')) die('skip');
 ?>
 --FILE--
 <?php
-class myZip extends ZipArchive {
-       private $test = 0;
-       public $testp = 1;
-       private $testarray = array();
-
-       public function __construct() {
-               $this->testarray[] = 1;
-               var_dump($this->testarray);
-       }
-}
-
-$z = new myZip;
-$z->testp = "foobar";
-var_dump($z);
+include dirname(__FILE__) . '/bug38943.inc';
 ?>
 --EXPECTF--
 array(1) {
http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/bug7658.phpt?r1=1.1.2.2&r2=1.1.2.3&diff_format=u
Index: php-src/ext/zip/tests/bug7658.phpt
diff -u php-src/ext/zip/tests/bug7658.phpt:1.1.2.2 
php-src/ext/zip/tests/bug7658.phpt:1.1.2.3
--- php-src/ext/zip/tests/bug7658.phpt:1.1.2.2  Mon May  7 18:03:00 2007
+++ php-src/ext/zip/tests/bug7658.phpt  Wed Nov 12 11:59:26 2008
@@ -2,11 +2,28 @@
 Bug #7658 (modify archive with general bit flag 3 set)
 --SKIPIF--
 <?php
-/* $Id: bug7658.phpt,v 1.1.2.2 2007/05/07 18:03:00 tony2001 Exp $ */
+/* $Id: bug7658.phpt,v 1.1.2.3 2008/11/12 11:59:26 pajoye Exp $ */
 if(!extension_loaded('zip')) die('skip');
 ?>
 --FILE--
 <?php
+$expect = array(
+       "mimetype",
+       "Configurations2/statusbar/",
+       "Configurations2/accelerator/current.xml",
+       "Configurations2/floater/",
+       "Configurations2/popupmenu/",
+       "Configurations2/progressbar/",
+       "Configurations2/menubar/",
+       "Configurations2/toolbar/",
+       "Configurations2/images/Bitmaps/",
+       "content.xml",
+       "styles.xml",
+       "meta.xml",
+       "Thumbnails/thumbnail.png",
+       "settings.xml",
+       "META-INF/manifest.xml",
+);
 $dirname = dirname(__FILE__) . '/';
 include $dirname . 'utils.inc';
 $file = $dirname . '__tmp_bug7658.odt';
@@ -16,45 +33,23 @@
        echo 'failed';
 }
 
-dump_entries_name($zip);
 
 $zip->deleteName('content.xml');
 $zip->addFile($dirname . "bug7658.xml","content.xml");
 $zip->close();
 echo "\n";
 $zip->open($file);
-dump_entries_name($zip);
[EMAIL PROTECTED]($file);
-?>
---EXPECT--
-0 mimetype
-1 Configurations2/statusbar/
-2 Configurations2/accelerator/current.xml
-3 Configurations2/floater/
-4 Configurations2/popupmenu/
-5 Configurations2/progressbar/
-6 Configurations2/menubar/
-7 Configurations2/toolbar/
-8 Configurations2/images/Bitmaps/
-9 content.xml
-10 styles.xml
-11 meta.xml
-12 Thumbnails/thumbnail.png
-13 settings.xml
-14 META-INF/manifest.xml
 
-0 mimetype
-1 Configurations2/statusbar/
-2 Configurations2/accelerator/current.xml
-3 Configurations2/floater/
-4 Configurations2/popupmenu/
-5 Configurations2/progressbar/
-6 Configurations2/menubar/
-7 Configurations2/toolbar/
-8 Configurations2/images/Bitmaps/
-9 styles.xml
-10 meta.xml
-11 Thumbnails/thumbnail.png
-12 settings.xml
-13 META-INF/manifest.xml
-14 content.xml
+for($i=0; $i < $zip->numFiles; $i++) {
+       $sb = $zip->statIndex($i);
+       $found[] = $sb['name'];
+}
+$ar = array_diff($found, $expect);
+
+var_dump($ar);
+unset($zip);
+unlink($file);
+?>
+--EXPECTF--
+array(0) {
+}
http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/oo_delete.phpt?r1=1.1&r2=1.1.2.1&diff_format=u
Index: php-src/ext/zip/tests/oo_delete.phpt
diff -u php-src/ext/zip/tests/oo_delete.phpt:1.1 
php-src/ext/zip/tests/oo_delete.phpt:1.1.2.1
--- php-src/ext/zip/tests/oo_delete.phpt:1.1    Mon Jul 24 16:58:58 2006
+++ php-src/ext/zip/tests/oo_delete.phpt        Wed Nov 12 11:59:26 2008
@@ -2,7 +2,7 @@
 Delete entries
 --SKIPIF--
 <?php
-/* $Id: oo_delete.phpt,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */
+/* $Id: oo_delete.phpt,v 1.1.2.1 2008/11/12 11:59:26 pajoye Exp $ */
 if(!extension_loaded('zip')) die('skip');
 ?>
 --FILE--
@@ -63,7 +63,12 @@
 var_dump($sb);
 $sb = $zip->statIndex(2);
 var_dump($sb);
[EMAIL PROTECTED]($file);
+$zip->close();
+unset($zip);
+
+if (file_exists($file)) {
+       unlink($file);
+}
 ?>
 --EXPECTF--
 ok

http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/bug14962.phpt?view=markup&rev=1.1
Index: php-src/ext/zip/tests/bug14962.phpt
+++ php-src/ext/zip/tests/bug14962.phpt
--TEST--
Bug #14962 (::extractTo second argument is not really optional)
--SKIPIF--
<?php
/* $Id: bug14962.phpt,v 1.1 2008/11/12 11:24:48 pajoye Exp $ */
if(!extension_loaded('zip')) die('skip');
?>
--FILE--
<?php

$dir = dirname(__FILE__);
$file = '__tmp14962.txt';
$fullpath = $dir . '/' . $file;
$za = new ZipArchive;
$za->open($dir . '/__14962.zip', ZIPARCHIVE::CREATE);
$za->addFromString($file, '1234');
$za->close();

if (!is_file($dir . "/__14962.zip")) {
        die('failed to create the archive');
}
$za = new ZipArchive;
$za->open($dir . '/__14962.zip');
$za->extractTo($dir, NULL);
$za->close();

if (is_file($fullpath)) {
        unlink($fullpath);
        echo "Ok";
}
unlink($dir . '/' . '__14962.zip');
?>
--EXPECT--
Ok

http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/bug38943.inc?view=markup&rev=1.1
Index: php-src/ext/zip/tests/bug38943.inc
+++ php-src/ext/zip/tests/bug38943.inc

http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/bug38943_2.phpt?view=markup&rev=1.1
Index: php-src/ext/zip/tests/bug38943_2.phpt
+++ php-src/ext/zip/tests/bug38943_2.phpt

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

Reply via email to