6

I had a real problem with SUPEE-8788 related to the decision to replace PHP's unserialize() function with the new Unserialize_Parser. The problem is that the Gene_Braintree payment extension sets NULL values in the additional_data array saved in the payment quote. This was causing the exception "Unsupported data type N" to be thrown at checkout.

Here's how I solved this:

  1. Added const TYPE_NULL = 'N'; to lib/Unserialize/Parser.php
  2. Created a new class Unserialize_Reader_Null (full code below)
  3. Added a case to the switch statement in lib/Unserialize/Reader/ArrValue.php to check for my new TYPE_NULL character and instantiate a new Unserialize_Reader_Null() if it is found

New file lib/Unserialize/Reader/Null.php:

<?php
class Unserialize_Reader_Null
{
    /**
     * @var int
     */
    protected $_status;

    /**
     * @var string|int
     */
    protected $_value;

    const READING_VALUE = 1;

    /**
     * @param string $char
     * @param string $prevChar
     * @return int|null
     */
    public function read($char, $prevChar)
    {
        if ($char == Unserialize_Parser::TYPE_NULL) {
            return null;
        }
        else if ($char == Unserialize_Parser::SYMBOL_SEMICOLON) {
            return '';
        }
    }
}
2

This bug was fixed in SUPEE-8788 V2, I reckon you should install that version to ensure you did not miss anything else ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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