|  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-01-22 22:28 UTC
From: kris dot rande at infinite dot com Assigned:
Status: Open Package: Zip Related
PHP Version: 7.4.1 OS: Ubuntu 16
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: kris dot rande at infinite dot com
New email:
PHP Version: OS:


 [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

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-22 22:28 UTC]
-Package: zip +Package: Zip Related
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Feb 19 23:01:29 2020 UTC