Merge branch 'PHP-8.0' into PHP-8.1

* PHP-8.0:
  NEWS
  Fix GH-8781 ZipArchive::close deletes zip file without updating stat cache
This commit is contained in:
Remi Collet 2022-06-15 15:39:00 +02:00
commit c76374d26f
No known key found for this signature in database
GPG key ID: DC9FF8D3EE5AF27F
2 changed files with 24 additions and 0 deletions

View file

@ -1571,6 +1571,9 @@ PHP_METHOD(ZipArchive, close)
ze_obj->err_sys = 0;
}
/* clear cache as empty zip are not created but deleted */
php_clear_stat_cache(1, ze_obj->filename, ze_obj->filename_len);
efree(ze_obj->filename);
ze_obj->filename = NULL;
ze_obj->filename_len = 0;

View file

@ -0,0 +1,21 @@
--TEST--
Bug GH-8781 (ZipArchive deletes zip file with no contents)
--SKIPIF--
<?php
if (!extension_loaded('zip')) die('skip zip extension not available');
?>
--FILE--
<?php
touch($file = __DIR__ . '/bug_gh8781.zip');
var_dump(is_file($file));
$zip = new ZipArchive();
$zip->open($file, ZipArchive::CREATE | ZipArchive::OVERWRITE);
$zip->close();
var_dump(is_file($file));
?>
--EXPECT--
bool(true)
bool(false)