meanbee / magento2-serviceworker

Service Worker extension for Magento 2
MIT License
52 stars 27 forks source link

Unserialize Error #9

Closed davidbrandastic closed 6 years ago

davidbrandastic commented 6 years ago

Started testing this today and ran into an error preventing the serviceworker.js from being rendered correctly.

main.CRITICAL: Notice: unserialize(): Error at offset 0 of 60 bytes in ----\vendor\meanbee\magento2-serviceworker\src\Helper\Config.php on line 69 [] []

image

After checking the config it appears that web/serviceworker/custom_strategies is stored as a json encoded array rather than a serialized array, thus causing the unserialize to fail. Changing unserialize to json_decode seems to clear up the issue with the logged error and the empty serviceworker.js

Tested on: Clean composer install of Magento 2.2.1, meanbee/magento2-serviceworker, and meanbee/magento2-webappmanifest

tgerulaitis commented 6 years ago

Looks like Magento changed their Magento\Config\Model\Config\Backend\Serialized\ArraySerialized class to use Json instead of serialize() :man_facepalming:

We'll need to:

  1. Update \Meanbee\ServiceWorker\Setup\InstallData to use the same serializer Magento uses when saving initial values.
  2. Update \Meanbee\ServiceWorker\Helper\Config::getCustomStrategies to also use the serializer class instead of raw unserialize() method.