Magento Fehlermeldung

We had the problem that we were greeted by the following error message when loading the Magento page:

 

Magento\Framework\Serialize\Serializer\Serialize>Magento\Framework\Serialize\Serializer\{closure}(8, 'unserialize(): ...', 'C:\\xampp\\...', 42, Array)

 

The curious thing about this message, however, was that we had actually already solved this problem. However, this was on a different local installation. After synchronizing via Git, the error occurred again on 2 of the 3 local installations, even though the solution had been transferred completely.

 

After searching for some time, we found the solution.

 

 

But let's start from the beginning. The original solution was as follows:

 

First, open the file:

 

App/code/Diglin/Serialize/Serializer/Json.php

 

Delete the entire contents of the file and replace them with the following code:

 

namespace Diglin\Username\Serialize\Serializer;

class Json extends \Magento\Framework\Serialize\Serializer\Json

{

/**

* {@inheritDoc}

* @since 100.2.0

*/

public function unserialize($string)

{

if($this->is_serialized($string))

{

$string = $this->serialize($string);

}

$result = json_decode($string, true);

}

if (json_last_error() !== JSON_ERROR_NONE) {

throw new \InvalidArgumentException('Unable to unserialize value.');

}

return $result;

}

function is_serialized($value, &$result = null)

{

// Bit of a give away this one

if (!is_string($value))

{

return false;

}

// Serialized false, return true. unserialize() returns false on an

// invalid string or it could return false if the string is serialized

// false, eliminate that possibility.

if ($value === 'b:0;')

{

$result = false;

return true;

}

$length = strlen($value);

$end = '';

switch ($value[0])

{

case 's':

if ($value[$length - 2] !== '"')

{

return false;

}

case 'b':

case 'i':

case 'd':

// This looks odd but it is quicker than isset()ing

$end .= ';';

case 'a':

case 'O':

$end .= '}';

if ($value[1] !== ':')

{

return false;

}

switch ($value[2])

{

case 0:

case 1:

case 2:

case 3:

case 4:

case 5:

case 6:

case 7:

case 8:

case 9:

break;

default:

return false;

}

case 'N':

$end .= ';';

if ($value[$length - 1] !== $end[0])

{

return false;

}

break;

default:

return false;

}

if (($result = @unserialize($value)) === false)

{

$result = null;

return false;

}

return true;

}

}

 

Next, add the following to the file

 

App/etc/di.xml

 

:

 

 

< preference for="Magento\Framework\Indexer\Config\DependencyInfoProviderInterface" type="Magento\Framework\Indexer\Config\DependencyInfoProvider" />

 

And this is exactly where the difference between our original solution and the new one lies.

 

If you place the code mentioned above below

 

<preference for="Magento\Framework\Serialize\Serializer\Json" type="Diglin\Username\Serialize\Serializer\Json" />

 

the error will continue to occur. However, if you place the code above it, everything works perfectly.