php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
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
Description:
------------
---
From manual page: https://php.net/ziparchive.setcompressionname
---

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:
---------------
<?php
$zip = new ZipArchive;
$res = $zip->open('test.zip', ZipArchive::CREATE);
if ($res === TRUE) {
    $zip->addFile('foo.jpg', 'foo', 'Some text');
    $zip->setCompressionName('foo', ZipArchive::CM_STORE);
    $zip->close();
    echo 'ok';
} else {
    echo 'failed';
}
?>


Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-22 22:28 UTC] cmb@php.net
-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:  https://github.com/php/pecl-database-mysql_xdevapi/pull/8
Patch:      https://github.com/php/pecl-database-mysql_xdevapi/pull/8.patch
 [2020-03-18 12:35 UTC] remi@php.net
Automatic comment from SVN on behalf of remi
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=349488
Log: add another ex from #79157
 [2020-03-18 12:36 UTC] remi@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: remi
 [2020-03-18 12:37 UTC] remi@php.net
-Status: Assigned +Status: Closed
 [2020-03-18 12:37 UTC] remi@php.net
The fix for this bug has been committed.
If you are still experiencing this bug, try to check out latest source from https://github.com/php/php-src and re-test.
Thank you for the report, and for helping us make PHP better.


 [2020-03-19 00:58 UTC] mumumu@php.net
Automatic comment from SVN on behalf of mumumu
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=349491
Log: add another ex from #79157
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 15:01:29 2024 UTC