php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #51541 ZipArchive::addFile does not really add files
Submitted: 2010-04-12 11:37 UTC Modified: 2010-10-23 08:12 UTC
From: juwe at clasennet dot de Assigned: kalle (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3SVN-2010-04-12 (SVN) OS: Linux
Private report: No CVE-ID: None
 [2010-04-12 11:37 UTC] juwe at clasennet dot de
Description:
------------
Could you please let the documentation for ZipArchive::addFile() reflect, that the function doesn't really add the added files content to the zip archive any longer?

As it seems, the files content is only read when storing the files now, as opposed to 5.2.8. So, if you delete a file directly after adding it to a zip archive, the archive won't be created any longer.

I'm not really sure, if this is a bug, since the return value of addFile() isn't true any longer, or if this is just a documentation problem.

Personaly, I don't care either way. I just spend about two hours, until I realized where the problem was. Having a reminder in the docs would have reduced this time down to about five minutes...

There is a bug report (#40494) talking about such information in the manual, but the bug was marked bogus, and the manual was never updated. Essentially, that's why I opened this one as a documentation problem.

Test script:
---------------
<?php
  // works in PHP 5.2.8:

  $zipArchive='/path/2/my/archive';
  $filesToAdd=array('/path/2/file1.ext',
                    '/path/2/file2.ext',
                    '/path/2/file3.ext');

  $zip=new ZipArchive();
  if(true===$zip->open($zipArchive,ZIPARCHIVE::CREATE))
    foreach($filesToAdd as $file)
      if($zip->addFile($file,basename($file)))
        unlink($file);
    
  $zip->close();

  /* Expected result:
   *   Zip archive exists and contains the right data
   *
   * Actual result:
   *   Version 5.2.8: 
   *     - Works flawlessly & as expected
   *   Version 5.3.99-dev
   *     - No zip archive created
   *     - ZipArchive::GetStatusString reports a read error, 
   *       but only after closing the file
   */
?>

Expected result:
----------------
Zip archive exists and contains the right data.

Actual result:
--------------
Version 5.2.8: 
  - Works flawlessly & as expected

Version 5.3.99-dev
  - No zip archive created
  - ZipArchive::GetStatusString reports a read error, 
    but only after closing the file

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-12 11:41 UTC] pajoye@php.net
This behavior was the same in previous before but you would not be able to actually delete the file (file lock).

It should definitively be part of the documentation.
 [2010-06-30 00:47 UTC] brianwigginton at gmail dot com
This nailed me for about 3 hours earlier today. Documentation revision would be killer!

ZipArchive::GetStatusString reports a read error, but only after closing the file
 [2010-06-30 01:01 UTC] philip@php.net
-Assigned To: +Assigned To: pajoye
 [2010-10-22 15:48 UTC] kalle@php.net
-Status: Assigned +Status: Open -Package: Zip Related +Package: Documentation problem -Assigned To: pajoye +Assigned To:
 [2010-10-23 08:12 UTC] kalle@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=304638
Log: Fixed bug #51541 (ZipArchive::addFile does not really add files)
 [2010-10-23 08:12 UTC] kalle@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: kalle
 [2010-10-23 08:12 UTC] kalle@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2020-02-07 06:08 UTC] phpdocbot@php.net
Automatic comment on behalf of kalle
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=09eb46046a1bf7718c4cd581ed0db3134681ad7c
Log: Fixed bug #51541 (ZipArchive::addFile does not really add files)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 21:01:33 2024 UTC