go to bug id or search bugs for
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.
// Open new archive in cwd based on timestamp
$zip = new ZipArchive();
$open = $zip->open(time() . '.zip', ZipArchive::OVERWRITE);
Expected behavior: The new archive is opened as in the previous version.
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
Add a Pull Request
workaround is to use ZipArchive::CREATE | ZipArchive::OVERWRITE instead of ZipArchive::OVERWRITE
Thanks for the report.
Sorry to have missed this BC.
Actually, the bundled libzip had been patched in the past due to
bug #47667, and this later has be re-done again. 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.
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
Since system libzip is actually preferred in the meantime, we
won't customize the bundled libzip anymore. Thus, I'm switching
to doc issue.
Automatic comment from SVN on behalf of cmb
Log: Fix #71064: open($string, ZipArchive::OVERWRITE) does not create non-existing archives
We're taking the wording from the zip_open() documentation, and don't
care to document that ZipArchive::OVERWRITE implied ZipArchive::CREATE
in some formerly bundled libzips.
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation better.