Bug #53856 [Asn]: zipArchive::addPattern requires path parameter
| From: | pajoye@php.net | Date: | Thu, 27 Jan 2011 16:10:21 +0000 |
| Subject: | Bug #53856 [Asn]: zipArchive::addPattern requires path parameter | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-158245@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53856&edit=1
ID: 53856
Updated by: pajoye@php.net
Reported by: rquadling@php.net
Summary: zipArchive::addPattern requires path parameter
Status: Assigned
Type: Bug
Package: Zip Related
Operating System: Windows XP SP3
PHP Version: 5.3.5
Assigned To: pajoye
Block user comment: N
Private report: N
New Comment:
If the pattern begins with an absolute path or not is the key part. I
will take
care of that bug (something else to check as well).
Previous Comments:
------------------------------------------------------------------------
[2011-01-27 17:05:02] rquadling@php.net
If it is optional, then with a pattern that says include everything,
what path
should be examined? What is the default path?
If it is supposed to be optional, then I'd guess the current path should
be the
default?
------------------------------------------------------------------------
[2011-01-27 16:57:27] pajoye@php.net
It should be optional, making it mandatory is not correct.
------------------------------------------------------------------------
[2011-01-27 16:55:46] rquadling@php.net
The supplied patch makes the path parameter mandatory.
------------------------------------------------------------------------
[2011-01-27 16:46:04] rquadling@php.net
Description:
------------
php --rf zipArchive::addPattern tells us that the path is optional. This
is
confirmed by the parameter parsing.
But, at least on windows, if no path is supplied, with a pattern that
will include
everything, no files are added.
Setting the path to the current directory (for example) will include all
files in
that directory (using the same regex).
Test script:
---------------
<?php
$zip = new ZipArchive;
if (True === $zip->open('./TestAddPattern.zip', ZIPARCHIVE::CREATE)) {
echo
'Add all files with no path param', PHP_EOL,
print_r($zip->addPattern('/.*/'), True), PHP_EOL,
'Number of files : ', $zip->numFiles, PHP_EOL,
'Add all files in current path param', PHP_EOL,
print_r($zip->addPattern('/.*/', '.'), True), PHP_EOL,
'Number of files : ', $zip->numFiles, PHP_EOL;
$zip->close();
}
Expected result:
----------------
Add all files with no path param
Array
(
[0] => .\25.BAT
...
[88] => .\upxit.bat
)
Number of files : 89
Add all files in current path param
Array
(
[0] => .\25.BAT
...
[88] => .\upxit.bat
)
Number of files : 178
Actual result:
--------------
Add all files with no path param
Number of files : 0
Add all files in current path param
Array
(
[0] => .\25.BAT
...
[88] => .\upxit.bat
)
Number of files : 89
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53856&edit=1