php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53166 ZipArchive::addFile() is missing parameters in docs
Submitted: 2010-10-26 14:34 UTC Modified: 2011-01-27 21:15 UTC
From: znarkus at gmail dot com Assigned: pajoye (profile)
Status: Closed Package: Zip Related
PHP Version: 5.3.3 OS:
Private report: No CVE-ID: None
 [2010-10-26 14:34 UTC] znarkus at gmail dot com
Description:
------------
If I understood the php_zip.c file, the declaration should be

public function addFile($fileName, $localname = '', $start = null, $end = null)

Using that declaration with PHP 5.3.3, I could extend ZipArchive which rendered errors otherwise.


Patches

php_zip.c__Reflection__Documentation (last revision 2010-12-07 14:08 UTC by [email protected])
php_zip.c__Reflection (last revision 2010-11-18 11:39 UTC by RQuadling at GMail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-26 14:35 UTC] znarkus at gmail dot com
On this URL: http://se.php.net/manual/en/function.ziparchive-addfile.php
 [2010-10-26 14:47 UTC] [email protected]
Interesting. Yes, the prototype could look like that, but the additional 
parameters would have no impact.

In both the addFile() and the addGlob() methods, the call to php_zip_add_file 
doesn't passes 0 for both the start and length parameters.

I'd not change the documentation to match these useless parameters.

Unless this bug is really that the values SHOULD be passed?
 [2010-10-26 16:51 UTC] znarkus at gmail dot com
Without them, I get the following error when extending the class.

Declaration of ZipArchiveImproved::addFile() should be compatible with that of ZipArchive::addFile()

ZipArchiveImproved is my custom class, and definition of addFile is as follows, which doesn't work.

public function addFile( $fileName, $localname = '')
 [2010-10-26 17:33 UTC] [email protected]
If the parameters exist, they should be documented, even if it means saying that 
they do nothing useful.
 [2010-10-26 17:38 UTC] znarkus at gmail dot com
Yeah, downloading the source and dissecting the C code is probably not rookie PHP'ers do, like I had to. One of the things PHP is known for is it's extensive documentation. Thanks for taking the time!
 [2010-10-26 17:47 UTC] [email protected]
-Assigned To: +Assigned To: rquadling
 [2010-10-26 18:18 UTC] [email protected]
-Package: Documentation problem +Package: Zip Related -Assigned To: rquadling +Assigned To:
 [2010-10-26 18:18 UTC] [email protected]
There would also be an issue with ZipArchive::setArchiveComment, ZipArchive::getCommentIndex, ZipArchive::getCommentName, ZipArchive::getNameIndex(), ZipArchive::getFromName() and ZipArchive::getFromIndex().

None of these methods documented prototypes tie up with the actual parameters being reflected by the extension.

Also, in some cases, the reflection doesn't tie up with the argument parsing in the C code.

Whilst, on the surface, this looks like a documentation bug, I think that the underlying code should be fixed and then accurate documentation can be written from that.

There are also missing function ZipArchive::addGlob() and ZipArchive::addPattern() are missing.
 [2010-10-26 18:25 UTC] [email protected]
-Assigned To: +Assigned To: pajoye
 [2010-10-26 18:25 UTC] [email protected]
Assigning to Pierre, he should help investigate this.
 [2010-10-26 18:30 UTC] [email protected]
Richard, also please use either the bug tracker or a direct mail, but not both.

I will look at these as soon as possible (but toooo soon).
 [2010-10-26 21:07 UTC] [email protected]
-Type: Documentation Problem +Type: Bug
 [2010-10-27 15:52 UTC] [email protected]
I've added a patch to this bug which I feel fixes the reflection/prototype issues 
in php_zip.c (branch/5.3)

If it could be reviewed and committed, then I can get the documentation in 
agreement with this.
 [2010-11-10 12:53 UTC] [email protected]
-Operating System: Windows +Operating System:
 [2010-11-18 12:39 UTC] [email protected]
New patch against 5.3 and trunk.
 [2010-12-07 15:06 UTC] [email protected]
The following patch has been added/updated:

Patch Name: php_zip.c__Reflection__Documentation
Revision:   1291730797
URL:        http://bugs.php.net/patch-display.php?bug=53166&patch=php_zip.c__Reflection__Documentation&revision=1291730797
 [2010-12-07 15:08 UTC] [email protected]
The following patch has been added/updated:

Patch Name: php_zip.c__Reflection__Documentation
Revision:   1291730925
URL:        http://bugs.php.net/patch-display.php?bug=53166&patch=php_zip.c__Reflection__Documentation&revision=1291730925
 [2011-01-27 12:47 UTC] [email protected]
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&revision=307778
Log: - Fix bug #53166,  missing parameters in reflections/docs
 [2011-01-27 12:47 UTC] [email protected]
-Status: Assigned +Status: Closed
 [2011-01-27 12:47 UTC] [email protected]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2011-01-27 12:55 UTC] [email protected]
Automatic comment from SVN on behalf of rquadling
Revision: http://svn.php.net/viewvc/?view=revision&revision=307780
Log: ZipArchive reflection and parameter parsing now match, and so should the documentation. Fixes docbug aspects to bug #53166
 [2011-01-27 21:15 UTC] znarkus at gmail dot com
Thank _you_ <3
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Dec 31 17:00:02 2025 UTC