mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Raise E_WARNING on PHP related errors
If Zip operations fails due to PHP error conditions before libzip even has been called, there is no meaningful indication what failed; the functions just return false, and the Zip status indicated that no error did occur. Therefore we raise `E_WARNING` in these cases. Closes GH-6356.
This commit is contained in:
parent
98e4f9466d
commit
d65a520b1d
4 changed files with 10 additions and 2 deletions
|
@ -288,11 +288,13 @@ static int php_zip_add_file(ze_zip_object *obj, const char *filename, size_t fil
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!expand_filepath(filename, resolved_path)) {
|
if (!expand_filepath(filename, resolved_path)) {
|
||||||
|
php_error_docref(NULL, E_WARNING, "No such file or directory");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
php_stat(resolved_path, strlen(resolved_path), FS_EXISTS, &exists_flag);
|
php_stat(resolved_path, strlen(resolved_path), FS_EXISTS, &exists_flag);
|
||||||
if (Z_TYPE(exists_flag) == IS_FALSE) {
|
if (Z_TYPE(exists_flag) == IS_FALSE) {
|
||||||
|
php_error_docref(NULL, E_WARNING, "No such file or directory");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1163,6 +1165,7 @@ PHP_FUNCTION(zip_open)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!expand_filepath(ZSTR_VAL(filename), resolved_path)) {
|
if(!expand_filepath(ZSTR_VAL(filename), resolved_path)) {
|
||||||
|
php_error_docref(NULL, E_WARNING, "No such file or directory");
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1444,6 +1447,7 @@ PHP_METHOD(ZipArchive, open)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(resolved_path = expand_filepath(ZSTR_VAL(filename), NULL))) {
|
if (!(resolved_path = expand_filepath(ZSTR_VAL(filename), NULL))) {
|
||||||
|
php_error_docref(NULL, E_WARNING, "No such file or directory");
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,8 @@ DONE
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
%s.txt
|
%s.txt
|
||||||
|
|
||||||
|
Warning: ZipArchive::addFile(): No such file or directory in %s on line %d
|
||||||
add failed
|
add failed
|
||||||
close ok
|
close ok
|
||||||
DONE
|
DONE
|
||||||
|
|
|
@ -37,6 +37,7 @@ if ($zip->status == ZIPARCHIVE::ER_OK) {
|
||||||
}
|
}
|
||||||
@unlink($file);
|
@unlink($file);
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECTF--
|
||||||
|
Warning: ZipArchive::addFile(): No such file or directory in %s on line %d
|
||||||
failed
|
failed
|
||||||
OK
|
OK
|
||||||
|
|
|
@ -37,6 +37,7 @@ if ($zip->status == ZIPARCHIVE::ER_OK) {
|
||||||
}
|
}
|
||||||
@unlink($file);
|
@unlink($file);
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECTF--
|
||||||
|
Warning: ZipArchive::addFile(): No such file or directory in %s on line %d
|
||||||
failed
|
failed
|
||||||
OK
|
OK
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue