pajoye Wed Nov 12 11:41:21 2008 UTC Added files: (Branch: PHP_5_3) /php-src/ext/zip/tests bug14962.phpt
Modified files: /php-src/ext/zip php_zip.c php_zip.h Log: - MFH: - #14962, makes extractTo 2nd argument really optional - replace ZEND_ENGINE_2_1 by PHP_ZIP_USE_OO http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.38.2.22&r2=1.1.2.38.2.23&diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.38.2.22 php-src/ext/zip/php_zip.c:1.1.2.38.2.23 --- php-src/ext/zip/php_zip.c:1.1.2.38.2.22 Sun Nov 2 21:19:38 2008 +++ php-src/ext/zip/php_zip.c Wed Nov 12 11:41:21 2008 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_zip.c,v 1.1.2.38.2.22 2008/11/02 21:19:38 felipe Exp $ */ +/* $Id: php_zip.c,v 1.1.2.38.2.23 2008/11/12 11:41:21 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -135,7 +135,7 @@ } /* }}} */ -#ifdef ZEND_ENGINE_2_1 +#ifdef PHP_ZIP_USE_OO /* {{{ php_zip_extract_file */ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int file_len TSRMLS_DC) { @@ -740,7 +740,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; @@ -760,7 +760,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; @@ -1417,7 +1417,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) @@ -2377,7 +2377,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)) { @@ -2585,7 +2585,7 @@ /* {{{ PHP_MINIT_FUNCTION */ static PHP_MINIT_FUNCTION(zip) { -#ifdef ZEND_ENGINE_2_1 +#ifdef PHP_ZIP_USE_OO zend_class_entry ce; memcpy(&zip_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); @@ -2668,7 +2668,7 @@ */ static PHP_MSHUTDOWN_FUNCTION(zip) { -#ifdef ZEND_ENGINE_2_1 +#ifdef PHP_ZIP_USE_OO zend_hash_destroy(&zip_prop_handlers); php_unregister_url_stream_wrapper("zip" TSRMLS_CC); #endif @@ -2683,7 +2683,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.38.2.22 2008/11/02 21:19:38 felipe Exp $"); + php_info_print_table_row(2, "Extension Version","$Id: php_zip.c,v 1.1.2.38.2.23 2008/11/12 11:41:21 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.3.2.7&r2=1.10.2.3.2.8&diff_format=u Index: php-src/ext/zip/php_zip.h diff -u php-src/ext/zip/php_zip.h:1.10.2.3.2.7 php-src/ext/zip/php_zip.h:1.10.2.3.2.8 --- php-src/ext/zip/php_zip.h:1.10.2.3.2.7 Thu Oct 23 16:12:55 2008 +++ php-src/ext/zip/php_zip.h Wed Nov 12 11:41:21 2008 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_zip.h,v 1.10.2.3.2.7 2008/10/23 16:12:55 pajoye Exp $ */ +/* $Id: php_zip.h,v 1.10.2.3.2.8 2008/11/12 11:41:21 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/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 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php