Bug #81222 [NEW]: ZipArchive Deletes 0-length file

From: Date: Sun, 04 Jul 2021 06:45:13 +0000
Subject: Bug #81222 [NEW]: ZipArchive Deletes 0-length file
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234796@lists.php.net to get a copy of this message
From: eclipsechasers2 at yahoo dot com Operating system: Windows 10 PHP version: 7.4.21 Package: Filesystem function related Bug Type: Bug Bug description:ZipArchive Deletes 0-length file 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 bug report at https://bugs.php.net/bug.php?id=81222&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81222&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81222&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81222&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81222&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81222&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81222&r=support Expected behavior: https://bugs.php.net/fix.php?id=81222&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81222&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81222&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81222&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81222&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81222&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81222&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81222&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81222&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81222&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81222&r=mysqlcfg

« previous php.bugs (#234796) next »