My extension has stopped working since updating to Magento 2.2.0

When running di:compile we get the following error:

Errors during compilation:
            Incompatible argument type: Required type: \Vendor\Module\Model\ResourceModel\collection. Actual type: \Magento\Catalog\Model\ResourceModel\Product\Option\Collection; File:

            Incompatible argument type: Required type: \Vendor\Module\Model\ResourceModel\collection. Actual type: \Magento\Catalog\Model\ResourceModel\Product\Option\Collection; File:

Total Errors Count: 2

  Error during compilation

When checking exceptions.php we get the following error:

main.CRITICAL: Notice: unserialize(): Error at offset 0 of 169 bytes in /public_html/app/code/Vendor/Module/Model/StockProvider.php on line 181 {"exception":"[object] (Exception(code: 0): Notice: unserialize(): Error at offset 0 of 169 bytes in /public_html/app/code/Vendor/Module/Model/StockProvider.php on line 181 at /public_html/vendor/magento/framework/App/ErrorHandler.php:61)"}

No product can be added to the cart and the plugin isn't loading correctly on the product admin pages.

  • 2
    This module currently is not compatible with the Magento 2.2. If you have any questions - address them to the MageWorx support team (they provide a free lifetime support) Sep 29, 2017 at 13:22
  • I had, it was just taking too long to get it sorted so I branched out. Ended up rolling back to 2.1.9 while they make it compatible with 2.2.0
    – Justin
    Sep 29, 2017 at 15:08

3 Answers 3


As per magento 2.2 release note, Now you can not use direct serialize and unserialize PHP functions.

To solve this issue Inject \Magento\Framework\Serialize\Serializer\Json class for serialize and unserialize values.

public function __construct(
    \Magento\Framework\Serialize\Serializer\Json $serialize,
) {
    $this->serialize = $serialize;

Now use $this->serialize

 $this->serialize->unserialize($serializeVal); //To Unserialize Value
 $this->serialize->serialize($unserializeVal); //To Serialize Value

As per Magento 2.2 Release Note

Security enhancements

In general, we’ve removed serialize/unserialize from most the code to improve protection against remote code execution attacks. We’ve enhanced protection of code where use of object serialization or unserialization was unavoidable. Additionally, we’ve increased our use of output escaping to protect against cross-site scripting (XSS) attacks.

  • 1
    That's great thanks, Prince. I didn't catch that in the release.
    – Justin
    Oct 2, 2017 at 7:22
  • 1
    Great explanation for both version. Really appreciated.
    – Sharma
    Oct 3, 2017 at 10:39

1 Delete all the folders from pub/static

  1. Delete folders like cache, view_preprocessed, page_cache and generation from var folder.

  2. After that run command: php bin/magento setup:upgrade php bin/magento setup:static-content:deploy

Then error will be fixed.

  • Unfortunately that didn't fix the issue.
    – Justin
    Sep 29, 2017 at 2:05

This worked for me creating magento_umask file in the root directory with the appropriate umask for the server.

See http://devdocs.magento.com/guides/v2.2/install-gde/install/post-install-umask.html for additional details.

Not the answer you're looking for? Browse other questions tagged or ask your own question.