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

Affected version


Active member
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:


Active member
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.

DragonByte Tech

Well-known member
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.

XF Bug Bot

XenForo bug fixer bot
Staff member
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.