Doc #71064 [Csd]: open($string, ZipArchive::OVERWRITE) does not create non-existing archives

[email protected] Tue, 26 Apr 2022 17:00:00 +0000
Newsgroups php.doc.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=71064&edit=1

 ID:                 71064
 Updated by:         [email protected]
 Reported by:        php at rachuth dot de
 Summary:            open($string, ZipArchive::OVERWRITE) does not create
                     non-existing archives
 Status:             Closed
 Type:               Documentation Problem
 Package:            Zip Related
 Operating System:   *
 PHP Version:        5.6.16
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

> And now it seems to work properly.

Yeah, you're supposed to provide both constants (i.e.
ZipArchive::OVERWRITE does *not* imply ZipArchive::CREATE).


Previous Comments:
------------------------------------------------------------------------
[2022-04-26 16:48:33] lideln at gmail dot com

Am I the only one still having an issue today with PHP 8.1?

My code:

```
$oZip = new \ZipArchive();
if (($err = $oZip->open($sFile, \ZipArchive::OVERWRITE)) !== true)
```

Does not work from time to time. It is NOT a permission issue. I can totally use `touch($sFile)` and it works perfectly.

I fixed this by using:

```
$oZip = new \ZipArchive();
if (($err = $oZip->open($sFile, \ZipArchive::CREATE | \ZipArchive::OVERWRITE)) !== true)
```

And now it seems to work properly.

Feedback appreciated :)

Best,

------------------------------------------------------------------------
[2020-02-07 06:05:45] [email protected]

Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=47ef5a87daa67ac1968d435ee5a48d0dc9a38d72
Log: Fix #71064: open($string, ZipArchive::OVERWRITE) does not create non-existing archives

------------------------------------------------------------------------
[2018-05-08 22:00:52] [email protected]

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.

------------------------------------------------------------------------
[2018-05-08 22:00:02] [email protected]

Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=344995
Log: Fix #71064: open($string, ZipArchive::OVERWRITE) does not create non-existing archives

We're taking the wording from the zip_open() documentation[1], and don't
care to document that ZipArchive::OVERWRITE implied ZipArchive::CREATE
in some formerly bundled libzips.

[1] &lt;https://libzip.org/documentation/zip_open.html&gt;

------------------------------------------------------------------------
[2018-05-08 20:36:02] [email protected]

Since system libzip is actually preferred in the meantime[1], we
won't customize the bundled libzip anymore.  Thus, I'm switching
to doc issue.

[1] <https://github.com/php/php-src/commit/8857161bf2936bb807ac99c991509821bf7f1100#diff-18e07cc7a4680f60b944b30302e4bfa9>

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=71064


--
Edit this bug report at https://bugs.php.net/bug.php?id=71064&edit=1