Bug #66713 [Fbk->NoF]: Delete a file within a zip archive will not removed
| From: | php-bugs at lists dot php dot net | Date: | Sun, 26 Apr 2015 04:22:18 +0000 |
| Subject: | Bug #66713 [Fbk->NoF]: Delete a file within a zip archive will not removed | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-192347@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: php-bugs@lists.php.net
Reported by: prdatur at gmail dot com
Summary: Delete a file within a zip archive will not removed
-Status: Feedback
+Status: No Feedback
Type: Bug
Package: Zip Related
Operating System: Ubuntu 13.04
PHP Version: Irrelevant
Assigned To: cmb
Private report: N
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2015-04-16 12:30:52] cmb@php.net
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?
------------------------------------------------------------------------
[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