Edit report at https://bugs.php.net/bug.php?id=51857&edit=1
ID: 51857 Updated by: php-bugs@lists.php.net Reported by: nuabaranda at web dot de Summary: deleteName() for directories returns True on non-success -Status: Feedback +Status: No Feedback Type: Bug Package: Zip Related Operating System: Linux 2.6.27 PHP Version: 5.3.3-dev Assigned To: pajoye 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 "Open". Thank you. Previous Comments: ------------------------------------------------------------------------ [2012-05-24 03:14:22] maxspeed40k at gmail dot com reproduce the problem PHP Version: 5.4.3 OS: windows 7 ------------------------------------------------------------------------ [2010-09-14 15:19:48] paj...@php.net Please try using this snapshot: http://snaps.php.net/php5.3-latest.tar.gz For Windows: http://windows.php.net/snapshots/ I can't reproduce the problem, can you try again pls? ------------------------------------------------------------------------ [2010-05-21 19:41:42] phi...@php.net And for good measure: <?php define ('FILEPATH_ZIPFILE', '/tmp/test.zip'); /* Create the Zip file */ $zip = new ZipArchive; if ($zip->open(FILEPATH_ZIPFILE, ZIPARCHIVE::CREATE) === TRUE) { $zip->addFromString('foo.txt', 'foo'); $zip->addFromString('bar.txt', 'bar'); $zip->addEmptyDir('EmptyDirectory'); $zip->addEmptyDir('FullDirectory'); $zip->addFromString('FullDirectory/baz.txt', 'baz'); $zip->close(); } /* Mess with the Zip file */ $zip = new ZipArchive; if ($zip->open(FILEPATH_ZIPFILE) === TRUE) { /* Fails to delete */ $r1 = $zip->deleteName('EmptyDirectory'); /* Successful delete (note the appended '/' */ $r2 = $zip->deleteName('EmptyDirectory/'); /* Fails to delete */ $r3 = $zip->deleteName('FullDirectory'); /* Fails to delete, although returns true */ $r4 = $zip->deleteName('FullDirectory/'); $zip->close(); } /* Display the Zip file contents */ $zip = new ZipArchive; if ($zip->open(FILEPATH_ZIPFILE) === TRUE) { echo 'File count: ', $zip->numFiles, PHP_EOL; echo 'Status: ', $zip->status, PHP_EOL; for ($i = 0; $i < $zip->numFiles; $i++) { $stat = $zip->statIndex($i); echo 'Index: ', $i, ' ', $stat['name'], PHP_EOL; } $zip->close(); } var_dump( array('r1' => $r1, 'r2' => $r2, 'r3' => $r3, 'r4' => $r4) ); Returns: File count: 3 Status: 0 Index: 0 foo.txt Index: 1 bar.txt Index: 2 FullDirectory/baz.txt array(4) { ["r1"]=> bool(false) ["r2"]=> bool(true) ["r3"]=> bool(false) ["r4"]=> bool(true) } ------------------------------------------------------------------------ [2010-05-19 09:43:27] nuabaranda at web dot de Description: ------------ When trying to delete a non-empty directory in a ZIP file with deleteName() the function will return True and not delete the directory if it is not empty. Expectation would be to return False if the directory can not be deleted. Also the directory handling should be better documentated (usage of trailing slashes, examples). Test script: --------------- $zip = new ZipArchive; if( $zip->open('archive.zip', ZipArchive::CREATE) ) { $zip->addEmptyDir('folder'); $zip->addFile('folder/file.txt'); if( ! $zip->deleteName('folder/') ) { echo 'Should end up here if folder not deletable'; } } $zip->close(); Expected result: ---------------- Should echo. Actual result: -------------- Will not echo. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=51857&edit=1