Bug #81222 [Opn]: ZipArchive Deletes 0-length file
| From: | eclipsechasers2 at yahoo dot com | Date: | Mon, 05 Jul 2021 01:05:33 +0000 |
| Subject: | Bug #81222 [Opn]: ZipArchive Deletes 0-length file | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-234798@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81222&edit=1
ID: 81222
User updated by: eclipsechasers2 at yahoo dot com
Reported by: eclipsechasers2 at yahoo dot com
Summary: ZipArchive Deletes 0-length file
Status: Open
Type: Bug
Package: Filesystem function related
Operating System: Windows 10
PHP Version: 7.4.21
Block user comment: N
Private report: N
New Comment:
It looks like the problem can occur with non-zero-length files as well, though not as predictably.
Previous Comments:
------------------------------------------------------------------------
[2021-07-04 06:45:13] eclipsechasers2 at yahoo dot com
Description:
------------
On Windows, when a zero-length file is opened as a ZipArchive, the file is deleted when the zip is
closed. This seems to happen in all releases of PHP. It does not seem to happen on Linux systems.
Test script:
---------------
<?php
$filename = 'zerolengthfile.zip';
file_put_contents($filename, '');
assert(file_exists($filename));
$zip = new ZipArchive();
$zip->open($filename);
$zip->close();
assert(file_exists($filename));
Expected result:
----------------
I expect the assert at the end to not issue a message. I also expect zerolengthfile.zip to exist.
Actual result:
--------------
Warning: assert(): assert(file_exists($filename)) failed in C:\phpexceltest\Owen
\testfile2.php on line 8
zerolengthfile.zip does not exist
If the $zip->close() statement is removed, the assert at the end does not issue a message.
Nevertheless, zerolengthfile.zip does not exist when the script terminates.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81222&edit=1