This article covers a special case that may occur if you use the same dataset as us. We were aiming to update the current Magento version to the latest stable one – 2.3. * At the time of writing this article, the latest version was 2.3.4.
The update process was quite fast and trivial, so we will not go into detail about it. The issue we faced was not centered in the update process, but rather what we got as a result of its execution. Furthermore, we have a list of things that may occur after update, which can serve as a reference for you in what you might face after updating.
Unable to apply data patch Magento\Wishlist\Setup\Patch\Data\CleanUpData for module Magento_Wishlist
Original exception message: Unable to unserialize value. Error: Syntax error
Class
/vendor/magento/module-wishlist/Setup/Patch/Data/CleanUpData.php
line 81.
$rowValue = $this->json->unserialize($optionRow['value']);
A more detailed description. Everything found in the wishlist_item_option table cannot be unserialized for an unknown reason, so the update process cannot be completed properly and we cannot proceed to the next stage of testing.
What the function does. It selects data from the wishlist_item_option table, while the values in the “Value” column remain unserialized, and the login element is deleted from the resulting array.
After this, the array is serialized, and the data in the “Value” column is updated. To put it simply, certain secure data like logins is deleted.
We are of the opinion that the SQL query simply lacks the conditions to select entries responsible for the code='info_buyRequest' condition, because only this data is serialized and this condition gives us some assurance that you will be working with an array of data and not a single line. This can be attributed to the impossibility of executing a function for a line that is not serialized, causing the issue at hand.
Possible solutions
- The simplest – delete the file from the vendor folder (/vendor/magento/module-wishlist/Setup/Patch/Data/CleanUpData.php) because this class I no longer used.
- More complicated – suitable when you have no access to code (for instance, if Magento Cloud only allows reading of files). The only essential condition is that you must have access to the database.
Perform the following query to make sure that your table does not contain any secure data.
SQL Query
select JSON_EXTRACT(e.value, '$.login') AS login from wishlist_item_option AS e
WHERE e.code='info_buyRequest'
HAVING login IS NOT NULL
Make a backup of the wishlist_item_option table and then clear it out.
Continue the update procedure. The issue should be resolved.
After all of these modifications, restore the data of the wishlist_item_option table from the previously generated backup.