mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
Elevate warning to ValueError for invalid ZipArchive object
This commit is contained in:
parent
6902d14b81
commit
3c16606d46
@ -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); \
|
ze_zip_object *obj = Z_ZIP_P(object); \
|
||||||
intern = obj->za; \
|
intern = obj->za; \
|
||||||
if (!intern) { \
|
if (!intern) { \
|
||||||
php_error_docref(NULL, E_WARNING, "Invalid or uninitialized Zip object"); \
|
zend_value_error("Invalid or uninitialized Zip object"); \
|
||||||
RETURN_FALSE; \
|
return; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
@ -66,10 +66,10 @@ class ZipArchive
|
|||||||
/** @return bool */
|
/** @return bool */
|
||||||
public function close() {}
|
public function close() {}
|
||||||
|
|
||||||
/** @return int|false */
|
/** @return int */
|
||||||
public function count() {}
|
public function count() {}
|
||||||
|
|
||||||
/** @return string|false */
|
/** @return string */
|
||||||
public function getStatusString() {}
|
public function getStatusString() {}
|
||||||
|
|
||||||
/** @return bool */
|
/** @return bool */
|
||||||
|
@ -26,7 +26,11 @@ if (!$zip->open(__DIR__ . '/test.zip')) {
|
|||||||
}
|
}
|
||||||
if ($zip->status == ZIPARCHIVE::ER_OK) {
|
if ($zip->status == ZIPARCHIVE::ER_OK) {
|
||||||
var_dump($zip->close());
|
var_dump($zip->close());
|
||||||
var_dump($zip->close());
|
try {
|
||||||
|
$zip->close();
|
||||||
|
} catch (ValueError $err) {
|
||||||
|
echo $err->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
die("Failure");
|
die("Failure");
|
||||||
}
|
}
|
||||||
@ -39,7 +43,5 @@ NULL
|
|||||||
zip_close(): supplied resource is not a valid Zip Directory resource
|
zip_close(): supplied resource is not a valid Zip Directory resource
|
||||||
Object
|
Object
|
||||||
bool(true)
|
bool(true)
|
||||||
|
Invalid or uninitialized Zip object
|
||||||
Warning: ZipArchive::close(): Invalid or uninitialized Zip object in %s on line %d
|
|
||||||
bool(false)
|
|
||||||
Done
|
Done
|
||||||
|
Loading…
Reference in New Issue
Block a user