Bug #66713 [Asn->Fbk]: Delete a file within a zip archive will not removed

From: Date: Thu, 16 Apr 2015 12:30:53 +0000
Subject: Bug #66713 [Asn->Fbk]: Delete a file within a zip archive will not removed
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192132@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66713&edit=1 ID: 66713 Updated by: cmb@php.net Reported by: prdatur at gmail dot com Summary: Delete a file within a zip archive will not removed -Status: Assigned +Status: Feedback Type: Bug Package: Zip Related Operating System: Ubuntu 13.04 PHP Version: Irrelevant Assigned To: cmb Block user comment: N Private report: N New Comment: I'm not able to reproduce the reported behavior with recent PHP versions. Does the issue still persist? Which PHP version are you using (please fill out the PHP version field)? Have you made sure that the zip archive is not write protected? Previous Comments: ------------------------------------------------------------------------ [2014-02-14 16:12:25] prdatur at gmail dot com Description: ------------ --- From manual page: http://www.php.net/ziparchive.deleteindex --- When opening a zip with ZipArchive and then deleting a file. The method returns true, getStatusString also returns no errors, but the file still exists within the archive. Within the opened "Session" the file is correctly removed but it really the state is not written to the physical file so the removed file is not really removed. Test script: --------------- <?php $zip_filename = '/var/www/www.zip'; $zip = new ZipArchive; if ($zip->open($zip_filename) === TRUE) { for ($i = 0; $i < $zip->numFiles; $i++) { $filename = $zip->getNameIndex($i); echo $filename . "\n"; if($filename === 'b.txt') { echo "Could be deleted by index? " . ($zip->deleteIndex($i) ? 'yes' : 'no') . "\n"; } } echo "Status string before delete by name: " . $zip->getStatusString() . "\n"; echo "Could be deleted by name? " . ($zip->deleteName('b.txt') ? 'yes' : 'no') . "\n"; echo "Status string after delete by name: " . $zip->getStatusString() . "\n"; $zip->close(); echo "Verify content of zip archive:\n"; $zip2 = new ZipArchive; if ($zip2->open($zip_filename) === TRUE) { for ($i = 0; $i < $zip2->numFiles; $i++) { $filename = $zip2->getNameIndex($i); echo $filename . "\n"; } } $zip2->close(); } ?> Expected result: ---------------- Output: a.txt b.txt Could be deleted by index? yes Status string before delete by name: No error Could be deleted by name? no Status string after delete by name: Entry has been deleted Verify content of zip archive a.txt When changing to delete "a.txt" Output should be: a.txt Could be deleted by index? yes b.txt Status string before delete by name: No error Could be deleted by name? no Status string after delete by name: Entry has been deleted Verify content of zip archive b.txt Actual result: -------------- Output: a.txt b.txt Could be deleted by index? yes Status string before delete by name: No error Could be deleted by name? no Status string after delete by name: Entry has been deleted Verify content of zip archive a.txt b.txt When changing to delete "a.txt" Output is: a.txt Could be deleted by index? yes b.txt Status string before delete by name: No error Could be deleted by name? no Status string after delete by name: Entry has been deleted Verify content if zip archive: a.txt b.txt ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66713&edit=1

« previous php.bugs (#192132) next »