How to fix the «Unable to unserialize value» failure while upgrading Magento from 2.1.x to 2.2.x?

Replace the line


with the following one:

$result = unserialize($string);