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 rquadling@php.net)
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] rquadling@php.net
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] philip@php.net
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] rquadling@php.net
-Assigned To: +Assigned To: rquadling
 [2010-10-26 18:18 UTC] rquadling@php.net
-Package: Documentation problem +Package: Zip Related -Assigned To: rquadling +Assigned To:
 [2010-10-26 18:18 UTC] rquadling@php.net
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] philip@php.net
-Assigned To: +Assigned To: pajoye
 [2010-10-26 18:25 UTC] philip@php.net
Assigning to Pierre, he should help investigate this.
 [2010-10-26 18:30 UTC] pajoye@php.net
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] kalle@php.net
-Type: Documentation Problem +Type: Bug
 [2010-10-27 15:52 UTC] rquadling@php.net
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] rquadling@php.net
-Operating System: Windows +Operating System:
 [2010-11-18 12:39 UTC] rquadling@php.net
New patch against 5.3 and trunk.
 [2010-12-07 15:06 UTC] rquadling@php.net
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] rquadling@php.net
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] pajoye@php.net
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] pajoye@php.net
-Status: Assigned +Status: Closed
 [2011-01-27 12:47 UTC] pajoye@php.net
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] rquadling@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC