Fixed Unsupported operand type error when installing style archive

Russ

Well-known member
I'm running into this server error when trying to upgrade a style using a zip archive. I can use this same zip to import on multiple other sites just fine but I have run into this issue with two different client sites. (2.2.5 XF and style)



Code:
Error: Unsupported operand types in src/XF/Service/Style/ArchiveValidator.php at line 226
XF\Service\Style\ArchiveValidator->getKnownFileHashes() in src/XF/Service/Style/ArchiveValidator.php at line 202
XF\Service\Style\ArchiveValidator->isCoreFile() in src/XF/Service/Style/ArchiveValidator.php at line 135
XF\Service\Style\ArchiveValidator->validate() in src/XF/Service/Style/ArchiveImport.php at line 83
XF\Service\Style\ArchiveImport->validateContents() in src/XF/Service/Style/ArchiveImport.php at line 62
XF\Service\Style\ArchiveImport->validateArchive() in src/XF/Admin/Controller/Style.php at line 373
XF\Admin\Controller\Style->actionImport() in src/XF/Mvc/Dispatcher.php at line 350
XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 261
XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 113
XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 55
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2337
XF\App->run() in src/XF.php at line 488
XF::runApp() in admin.php at line 13
 
Actually, while it could be related to PHP 8.0, I suspect it might not be. I think it means that on those two sites there are one or more add-ons that have a malformed hashes.json file.

PHP:
$hashes += json_decode(file_get_contents($path), true);

If the json_decode here fails then the += operand would likely fail.

I'll move this to bugs so we can investigate further.
 
One site is on 7.4.19 while the other is 7.2.34, both running 2.2.5

My site where I develop the styles is on PHP 8, just downgraded to 7.2 to test the same zip and it seems like it's importing fine.
 
@Chris D , I compared a list of both site add-ons and found out they both run: https://xenforo.com/community/resources/litespeed-cache-for-xf2-community.6248/

I tried:

  1. Import the style archive on my stock forum (installed fine)
  2. Installed that plugin and tried importing the same archive (gave the error)
  3. Uninstalled the plugin and tried importing the same archive (still gives the same error).

Now I can't even install styles after the plugin is gone :D. Not entirely sure if I need to bring this up with them or it is a bug with XF somehow.
 
Just following up on this. Exporting XML's work fine but exporting as an archive throws the error. It appears if I remove any asset locations defined under the "Edit style" it'll export as an archive just fine.

This is with that plugin uninstalled but didn't start throwing the errors until that thing was installed.
 
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.2.6).

Change log:
Fix unsupported operand error when validating a style archive if hashes.json fails to decode correctly.
There may be a delay before changes are rolled out to the XenForo Community.
 
Top Bottom