php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50349 Problem with the function ZipArchive::deleteName()
Submitted: 2009-12-01 08:45 UTC Modified: 2009-12-01 12:00 UTC
From: c dot hugot at uniteam dot fr Assigned: pajoye (profile)
Status: Not a bug Package: Zip Related
PHP Version: 5.3SVN-2009-12-01 (SVN) OS: windows xp with wamp
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: c dot hugot at uniteam dot fr
New email:
PHP Version: OS:

 

 [2009-12-01 08:45 UTC] c dot hugot at uniteam dot fr
Description:
------------
I create an archive (.zip) with class ZipArchive, with four files into. 
And when I want to delete the last file, in this archive, the function deleteName() return true, but the file is not remove from the archive.
The three others files were correctly remove, but not the last.

Reproduce code:
---------------
---
From manual page: function.ziparchive-deletename
---

        private function myDelZipFile($p_sName){
            $l_oZip = new ZipArchive();                       
            if($l_oZip->open(RACCORDEMENT_ZIP_FILE_PATH . "/" . $_SESSION['step5']['zip_name'] . ".zip", ZIPARCHIVE::OVERWRITE) === true){
                $l_oZip->deleteName( $_SESSION['step5'][$p_sName . '_name']) === true;
                $l_oZip->close();                
                return true;
            }            
            return false;            
        }

Expected result:
----------------
The archive file ever contained the last file. 

Actual result:
--------------
The archive would be empty.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-01 08:49 UTC] jani@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2009-12-01 08:53 UTC] c dot hugot at uniteam dot fr
<?php

private function myDelZipFile($p_sName){
$l_oZip = new ZipArchive();                       
if($l_oZip->open(RACCORDEMENT_ZIP_FILE_PATH . "/" . $_SESSION['step5']['zip_name'] . ".zip", ZIPARCHIVE::OVERWRITE) === true){
$l_oZip->deleteName( $_SESSION['step5'][$p_sName.'_name']);      $l_oZip->close();
                
return true;
}            
return false;            
}

?>
 [2009-12-01 08:58 UTC] jani@php.net
Is that self-contained? I don't have your session available.
 [2009-12-01 09:15 UTC] c dot hugot at uniteam dot fr
In the code $_SESSION['step5'][$p_sName . '_name'] is the name of the file, that is in the archive file ($_SESSION['step5']['zip_name'] . ".zip" = the name of the archive file), and RACCORDEMENT_ZIP_FILE_PATH is the constant, that contained the path to the archive file.

I hope, that could help you to solve my problem. Thanks for your work.

Best regards.
 [2009-12-01 09:58 UTC] pajoye@php.net
Please provide a script we can use to reproduce your problem, not only a function.
 [2009-12-01 11:50 UTC] c dot hugot at uniteam dot fr
I found the cause of my problem, it provide of an error of my script.

The cause is the second argument passed to the method ZipArchive::open(), in my script it was ZIPARCHIVE::OVERWRITE. I suppress it and my script work correctly.

Sorry for my english, my useless bug reporting and the disarrangement.

Best regards,

Christophe HUGOT
 [2009-12-01 12:00 UTC] pajoye@php.net
Pas de probleme :)

Not a bug > bogus.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 00:01:27 2024 UTC