Duplicate Install from Zip with root folder files

Lukas W.

Well-known member
Affected version
2.1.0 Beta 4
Add-ons that ship files to the root folder currently fail on "Install/upgrade from archive" with File does not appear to be a valid add-on archive as expected.
 
Given the following zip file structure:

190070

It will produce the following error: "Could not process archive.zip: File does not appear to be a valid add-on archive as expected."

This is because if a file is found in the root of the zip, every single entry from ZipArchive::getNameIndex will begin with /:
Code:
string(11) "/LICENSE.md"
string(8) "/upload/"

This fails in numerous locations across the archive process.

Problem: protected function resolveAddOnFromZip(): The preg_match will never succeed when the first character is a /
Potential solution: Underneath $fileName = $zip->getNameIndex($i); add $fileName = $fileName{0} == '/' ? substr($fileName, 1) : $fileName;

Problem: public function validate(&$error = null): if (!$zip->locateName($jsonFile)) will fail when the first character is a /
Potential solution: Change the entire protected function getZipAddOnRootDir() to this:
PHP:
protected function getZipAddOnRootDir()
{
   $zip = $this->zip();
   $testFileName = $zip->getNameIndex(0);
   
   return ($testFileName{0} == '/' ? '/' : '') . "upload/src/addons/{$this->addOnId}";
}

Problem: `protected function getFsFileNameFromZipName($fileName)`: Almost every part of this fails when the first character is a /
Potential solution: Above if (substr($fileName, -1) === '/') add $fileName = $fileName{0} == '/' ? substr($fileName, 1) : $fileName;

Problem: protected function getHashFileName(): Fails for the same reason as the Validator service does
Potential solution: Change the entire protected function getZipAddOnRootDir() to this:
PHP:
protected function getZipAddOnRootDir()
{
   $zip = $this->zip();
   $testFileName = $zip->getNameIndex(0);
   
   return ($testFileName{0} == '/' ? '/' : '') . "upload/src/addons/{$this->addOnId}";
}

Even all of this did not enable addons to install correctly, though that may be an issue with my setup. I have to force quit Docker and restart it because the process hangs on "Processing" after confirming the batch action.


Fillip
 
I've been doing a fair bit of testing with this and so far I have not been able to reproduce the issue, exactly. Note that the issue isn't actually with XF 2.1, but I think actually with how the Zip archive was built.

I believe the add-on may have been built in XF 2.0.10 or XF 2.0.11 with the following bug present:

There were also some separate bugs in XF 2.1 Beta 1 and Beta 2.

So, my suggestion is to re-build the add-ons again using XF 2.0.12 or XF 2.1 Beta 4 and let us know if that changes the ability to then install that built add-on using XF 2.1.

If there are still problems, I'll need to know which version of XF built the archive, and also which OS it was built on, and ideally I'd need a copy of the built add-on for testing.
 
So, my suggestion is to re-build the add-ons again using XF 2.0.12 or XF 2.1 Beta 4 and let us know if that changes the ability to then install that built add-on using XF 2.1.
I can confirm that rebuilding an addon on 2.0.12 allows it to be successfully detected as a valid addon archive. It appears to have installed fine.


Fillip
 
It's also possible that some installs may be running into this bug (fix enclosed):
This may be failing the install when searching for the addon.json file, if the addon.json file happens to be at index 0 (which we were essentially evaluating as false and could not be found).
 
Thanks all.

So just to be clear, if any of your users report issues with installing your add-ons using XF 2.1 then the most likely needed action is to build the add-on release ZIP again using XF 2.0.12 or XF 2.1.0 Beta 5. Actually the XF 2.1.0 Beta the add-on was built with might not matter, but the user must be installing it on XF 2.1.0 Beta 5 or later.

Not really sure what to mark this one. We'll call it a duplicate as it's most likely one or more other bug reports.
 
Back
Top Bottom