|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #79157 Documentation unclear for ZipArchive::setCompressionName
Submitted: 2020-01-22 19:30 UTC Modified: 2020-03-18 12:37 UTC
From: kris dot rande at infinite dot com Assigned: remi (profile)
Status: Closed Package: Zip Related
PHP Version: 7.4.1 OS: Ubuntu 16
Private report: No CVE-ID: None
 [2020-01-22 19:30 UTC] kris dot rande at infinite dot com
From manual page:

The documentation for ZipArchive::setCompressionName is unclear about what to pass for the $name parameter.

I wrongly assumed the $name parameter was the path to the source file ($filename parameter when calling ZipArchive::addFile). Through experimentation I determined it is actually the local name (optional $localname parameter when calling ZipArchive::addFile).

This could be improved by using "$localname" in all ZipArchive methods.

It would also be helpful to provide a code example that shows ZipArchive::addFile and ZipArchive::setCompressionName used together. I've included a proposed example in the "Test script" section below.

Test script:
$zip = new ZipArchive;
$res = $zip->open('', ZipArchive::CREATE);
if ($res === TRUE) {
    $zip->addFile('foo.jpg', 'foo', 'Some text');
    $zip->setCompressionName('foo', ZipArchive::CM_STORE);
    echo 'ok';
} else {
    echo 'failed';


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-22 22:28 UTC]
-Package: zip +Package: Zip Related
 [2020-02-24 09:37 UTC] info at sepc dot ir
The following pull request has been associated:

Patch Name: fix typo: mysqlx => mysqlx_x
On GitHub:
 [2020-03-18 12:35 UTC]
Automatic comment from SVN on behalf of remi
Log: add another ex from #79157
 [2020-03-18 12:36 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: remi
 [2020-03-18 12:37 UTC]
-Status: Assigned +Status: Closed
 [2020-03-18 12:37 UTC]
The fix for this bug has been committed.
If you are still experiencing this bug, try to check out latest source from and re-test.
Thank you for the report, and for helping us make PHP better.

 [2020-03-19 00:58 UTC]
Automatic comment from SVN on behalf of mumumu
Log: add another ex from #79157
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Apr 02 20:01:23 2020 UTC