Skip to content

Commit 3c16606

Browse files
committed
Elevate warning to ValueError for invalid ZipArchive object
1 parent 6902d14 commit 3c16606

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

ext/zip/php_zip.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,8 @@ static int php_zip_parse_options(zval *options, zend_long *remove_all_path, char
372372
ze_zip_object *obj = Z_ZIP_P(object); \
373373
intern = obj->za; \
374374
if (!intern) { \
375-
php_error_docref(NULL, E_WARNING, "Invalid or uninitialized Zip object"); \
376-
RETURN_FALSE; \
375+
zend_value_error("Invalid or uninitialized Zip object"); \
376+
return; \
377377
} \
378378
}
379379
/* }}} */

ext/zip/php_zip.stub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ public function setPassword(string $password) {}
6666
/** @return bool */
6767
public function close() {}
6868

69-
/** @return int|false */
69+
/** @return int */
7070
public function count() {}
7171

72-
/** @return string|false */
72+
/** @return string */
7373
public function getStatusString() {}
7474

7575
/** @return bool */

ext/zip/tests/doubleclose.phpt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ if (!$zip->open(__DIR__ . '/test.zip')) {
2626
}
2727
if ($zip->status == ZIPARCHIVE::ER_OK) {
2828
var_dump($zip->close());
29-
var_dump($zip->close());
29+
try {
30+
$zip->close();
31+
} catch (ValueError $err) {
32+
echo $err->getMessage(), PHP_EOL;
33+
}
3034
} else {
3135
die("Failure");
3236
}
@@ -39,7 +43,5 @@ NULL
3943
zip_close(): supplied resource is not a valid Zip Directory resource
4044
Object
4145
bool(true)
42-
43-
Warning: ZipArchive::close(): Invalid or uninitialized Zip object in %s on line %d
44-
bool(false)
46+
Invalid or uninitialized Zip object
4547
Done

0 commit comments

Comments
 (0)