Fixed ErrorException: [E_WARNING] ZipArchive::addFile() when building release with libzip5 1.6.0


Active member
Affected version
Updated yum packages to:


When running php cmd.php xf-addon:build-release ... seeing error:
ErrorException: [E_WARNING] ZipArchive::addFile(): Invalid or uninitialized Zip object src/XF/Service/AddOn/ReleaseBuilder.php:413

The whole output:
Performing add-on export.
Exporting data for ...
Written successfully.
Attempting to validate addon.json file...
JSON file validates successfully!

Building release ZIP.

In ReleaseBuilder.php line 413:
  [E_WARNING] ZipArchive::addFile(): Invalid or uninitialized Zip object

xf-addon:build-release [--skip-hashes] [--] <id>

Admin panel shows "ZipArchive support: Yes".

Sample code works fine:

$zip = new ZipArchive;
$zip->open('', ZipArchive::CREATE);
Last edited:
Found the cause.

Function $zipArchive->open($this->tempFile, \ZipArchive::CREATE) fails with error code 19 (Not a zip archive).

The fix is to add ".zip" extension to $this->tempFile.

There should be some error check for output of $zipArchive->open, also.
I am also affected by this issue. I can confirm that changing the relevant line of src/XF/Service/AddOn/ReleaseBuilder.php to $this->tempFile = File::getTempFile() . '.zip'; fixes the issue.
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.1.8).

Change log:
Use \ZipArchive::OVERWRITE flag when creating add-on zip to maintain compatibility with newer libzip versions
There may be a delay before changes are rolled out to the XenForo Community.
Top Bottom