Doc #79157 [Com]: Documentation unclear for ZipArchive::setCompressionName
| From: | remi@php.net | Date: | Wed, 18 Mar 2020 12:36:35 +0000 |
| Subject: | Doc #79157 [Com]: Documentation unclear for ZipArchive::setCompressionName | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-17432@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79157&edit=1
ID: 79157
Comment by: remi@php.net
Reported by: kris dot rande at infinite dot com
Summary: Documentation unclear for
ZipArchive::setCompressionName
Status: Assigned
Type: Documentation Problem
Package: Zip Related
Operating System: Ubuntu 16
PHP Version: 7.4.1
Assigned To: remi
Block user comment: N
Private report: N
New Comment:
Second ex added in https://github.com/php/doc-en/commit/b709972b451ff912220d32456e48f0cab038fc15
Previous Comments:
------------------------------------------------------------------------
[2020-03-18 12:35:53] remi@php.net
Automatic comment from SVN on behalf of remi
Revision: http://svn.php.net/viewvc/?view=revision&revision=349488
Log: add another ex from #79157
------------------------------------------------------------------------
[2020-02-24 09:37:04] 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-01-22 19:30:30] 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';
}
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79157&edit=1