|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71064 open($string, ZipArchive::OVERWRITE) does not create non-existing archives
Submitted: 2015-12-08 14:56 UTC Modified: 2017-10-24 07:38 UTC
Avg. Score:4.0 ± 0.8
Reproduced:6 of 6 (100.0%)
Same Version:3 (50.0%)
Same OS:2 (33.3%)
From: php at rachuth dot de Assigned:
Status: Open Package: Zip Related
PHP Version: 5.6.16 OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-12-08 14:56 UTC] php at rachuth dot de
There is an issue with the ZipArchive class' open() method. In previous versions of PHP when the only flag passed to the method was the ZipArchive::OVERWRITE, the method also created non-existing archives.

Since PHP 5.6 the OVERWRITE flag alone cannot create new archives which breaks compatibility.

Test script:
// Open new archive in cwd based on timestamp 
$zip = new ZipArchive(); 
$open = $zip->open(time() . '.zip', ZipArchive::OVERWRITE); 
echo $open;

Expected result:
Expected behavior: The new archive is opened as in the previous version.

Actual result:
In PHP 5.5 an empty archive is opened.
In PHP 5.6 ZipArchive::ER_OPEN error code is returned (cannot open zip file).


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-16 19:34 UTC] jkeller at berkeley dot edu
workaround is to use ZipArchive::CREATE | ZipArchive::OVERWRITE instead of ZipArchive::OVERWRITE
 [2015-12-17 05:44 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: pajoye
 [2015-12-17 05:44 UTC]
Thanks for the report.

Sorry to have missed this BC.
 [2016-09-05 17:13 UTC]
Actually, the bundled libzip had been patched in the past due to
bug #47667, and this later has be re-done again[1]. This patch
causes different behavior with the bundled and a system libzip,
so, in my opinion, it is good that we don't patch libzip anymore.
I guess that this difference is the cause of the confusion
regarding several user notes[2].

Considering that the behavioral change is already around for
nearly 2 years (and always has been for system libzip), it might
be best to stick with the current behavior, and update the manual

[1] <>
[2] <>
 [2017-10-24 07:38 UTC]
-Status: Assigned +Status: Open -Assigned To: pajoye +Assigned To:
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC