]> granicus.if.org Git - php/commitdiff
don't use deprecated libzip call
authorRemi Collet <remi@fedoraproject.org>
Wed, 6 May 2015 12:43:47 +0000 (14:43 +0200)
committerRemi Collet <remi@php.net>
Wed, 6 May 2015 13:16:43 +0000 (15:16 +0200)
ext/zip/php_zip.c
ext/zip/zip_stream.c

index 991ab9022027f93c5a5272383d76d69f78742373..f8b6a88fd71b26ed26e9657901db6a9df98b5b35 100644 (file)
@@ -395,18 +395,36 @@ static int php_zip_parse_options(zval *options, zend_long *remove_all_path, char
 
 static int php_zip_status(struct zip *za) /* {{{ */
 {
+#if LIBZIP_VERSION_MAJOR < 1
        int zep, syp;
 
        zip_error_get(za, &zep, &syp);
+#else
+       int zep;
+       zip_error_t *err;
+
+       err = zip_get_error(za);
+       zep = zip_error_code_zip(err);
+       zip_error_fini(err);
+#endif
        return zep;
 }
 /* }}} */
 
 static int php_zip_status_sys(struct zip *za) /* {{{ */
 {
+#if LIBZIP_VERSION_MAJOR < 1
        int zep, syp;
 
        zip_error_get(za, &zep, &syp);
+#else
+       int syp;
+       zip_error_t *err;
+
+       err = zip_get_error(za);
+       syp = zip_error_code_system(err);
+       zip_error_fini(err);
+#endif
        return syp;
 }
 /* }}} */
@@ -1505,8 +1523,12 @@ static ZIPARCHIVE_METHOD(getStatusString)
 {
        struct zip *intern;
        zval *self = getThis();
+#if LIBZIP_VERSION_MAJOR < 1
        int zep, syp, len;
        char error_string[128];
+#else
+       zip_error_t *err;
+#endif
 
        if (!self) {
                RETURN_FALSE;
@@ -1514,10 +1536,16 @@ static ZIPARCHIVE_METHOD(getStatusString)
 
        ZIP_FROM_OBJECT(intern, self);
 
+#if LIBZIP_VERSION_MAJOR < 1
        zip_error_get(intern, &zep, &syp);
 
        len = zip_error_to_str(error_string, 128, zep, syp);
        RETVAL_STRINGL(error_string, len);
+#else
+       err = zip_get_error(intern);
+       RETVAL_STRING(zip_error_strerror(err), 1);
+       zip_error_fini(err);
+#endif
 }
 /* }}} */
 
index 18707eed279a3a1c62553ab5b3f5ff72ea613017..3ae3e34f1308e508126a51e7614c2363c5f8ae9a 100644 (file)
@@ -52,10 +52,18 @@ static size_t php_zip_ops_read(php_stream *stream, char *buf, size_t count)
        if (self->za && self->zf) {
                n = zip_fread(self->zf, buf, count);
                if (n < 0) {
+#if LIBZIP_VERSION_MAJOR < 1
                        int ze, se;
                        zip_file_error_get(self->zf, &ze, &se);
                        stream->eof = 1;
                        php_error_docref(NULL, E_WARNING, "Zip stream error: %s", zip_file_strerror(self->zf));
+#else
+                       zip_error_t *err;
+                       err = zip_file_get_error(self->zf);
+                       stream->eof = 1;
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Zip stream error: %s", zip_error_strerror(err));
+                       zip_error_fini(err);
+#endif
                        return 0;
                }
                /* cast count to signed value to avoid possibly negative n