From 3c16606d462c3dde92438111a6c8a3d311a1254d Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 29 Sep 2019 13:58:45 +0200 Subject: [PATCH] Elevate warning to ValueError for invalid ZipArchive object --- ext/zip/php_zip.c | 4 ++-- ext/zip/php_zip.stub.php | 4 ++-- ext/zip/tests/doubleclose.phpt | 10 ++++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 257cfe4edd..cba217f1de 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -372,8 +372,8 @@ static int php_zip_parse_options(zval *options, zend_long *remove_all_path, char ze_zip_object *obj = Z_ZIP_P(object); \ intern = obj->za; \ if (!intern) { \ - php_error_docref(NULL, E_WARNING, "Invalid or uninitialized Zip object"); \ - RETURN_FALSE; \ + zend_value_error("Invalid or uninitialized Zip object"); \ + return; \ } \ } /* }}} */ diff --git a/ext/zip/php_zip.stub.php b/ext/zip/php_zip.stub.php index e86abd6bed..988aeef1ff 100644 --- a/ext/zip/php_zip.stub.php +++ b/ext/zip/php_zip.stub.php @@ -66,10 +66,10 @@ class ZipArchive /** @return bool */ public function close() {} - /** @return int|false */ + /** @return int */ public function count() {} - /** @return string|false */ + /** @return string */ public function getStatusString() {} /** @return bool */ diff --git a/ext/zip/tests/doubleclose.phpt b/ext/zip/tests/doubleclose.phpt index 771801952b..eb0ed7a829 100644 --- a/ext/zip/tests/doubleclose.phpt +++ b/ext/zip/tests/doubleclose.phpt @@ -26,7 +26,11 @@ if (!$zip->open(__DIR__ . '/test.zip')) { } if ($zip->status == ZIPARCHIVE::ER_OK) { var_dump($zip->close()); - var_dump($zip->close()); + try { + $zip->close(); + } catch (ValueError $err) { + echo $err->getMessage(), PHP_EOL; + } } else { die("Failure"); } @@ -39,7 +43,5 @@ NULL zip_close(): supplied resource is not a valid Zip Directory resource Object bool(true) - -Warning: ZipArchive::close(): Invalid or uninitialized Zip object in %s on line %d -bool(false) +Invalid or uninitialized Zip object Done -- 2.40.0