|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70103 ZipArchive::addGlob ignores remove_all_path option
Submitted: 2015-07-20 13:21 UTC Modified: 2017-01-06 14:54 UTC
Avg. Score:4.5 ± 0.5
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: cronoklee at hotmail dot com Assigned: cmb (profile)
Status: Closed Package: zip (PECL)
PHP Version: 5.6.11 OS: *
Private report: No CVE-ID: None
 [2015-07-20 13:21 UTC] cronoklee at hotmail dot com
From manual page:

After creating a zip archive using addGlob, the zip appears empty in Windows explorer due to the directory path being prepended to the files.

Test script:
$dir = '../temp';
$zip = new ZipArchive();
$zip -> open('../', ZipArchive::OVERWRITE);
$zip -> addGlob( $dir.'/*.txt', GLOB_NOSORT, array('remove_all_path' => TRUE) );
$zip -> close();

Expected result:
The 'remove_all_path'=>TRUE flag should place the files in the root directory of the zip archive.

NOTE: a workaround is to add a space before each file path name using the 'add_path' flag like so:
array('add_path' => ' ','remove_all_path' => TRUE)

Actual result:
Despite the 'remove_all_path'=>TRUE flag, the zipped files DO contain the '../temp' prefix, meaning that they cannot be read in Windows explorer.


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-20 14:33 UTC]
-Status: Open +Status: Analyzed
 [2015-07-20 14:33 UTC]
I can confirm this issue. It seems that the remove_all_path option
is properly processed and file_stripped holds the filename without
the path[1], but if no add_path option is given, file_stipped is
simply ignored when constructing the entry_name[2].

[1] <>
[2] <>
 [2015-07-20 15:17 UTC]
-Summary: ZipArchive -> addGlob creating empty directories in for Windows +Summary: ZipArchive::addGlob ignores remove_all_path option -Operating System: CentOS 6 +Operating System: * -PHP Version: 5.5.27 +PHP Version: 5.6.11
 [2017-01-06 05:42 UTC]
Automatic comment on behalf of cmb
Log: Fix #70103: ZipArchive::addGlob ignores remove_all_path option
 [2017-01-06 05:42 UTC]
-Status: Analyzed +Status: Closed
 [2017-01-06 14:51 UTC]
Automatic comment on behalf of
Log: Fix #70103: Fix bug 70103 when ZTS is enabled
 [2017-01-06 14:54 UTC]
-Assigned To: +Assigned To: cmb
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 21 15:01:29 2024 UTC