public static function decodePhpSerialize( $data ) {
		if ( !is_string( $data ) ) {
			throw new \InvalidArgumentException( '$data must be a string' );
		}

		$error = null;
		set_error_handler( function ( $errno, $errstr ) use ( &$error ) {
			$error = $errstr;
			return true;
		} );
		$ret = unserialize( $data );
		restore_error_handler();

		if ( $error !== null ) {
			self::$logger->error( 'PHP unserialization failed: ' . $error );
			return null;
		}

		// PHP strangely allows non-arrays to session_decode(), even though
		// that breaks $_SESSION. Let's not do that.
		if ( !is_array( $ret ) ) {
			self::$logger->error( 'PHP unserialization failed (value was not an array)' );
			return null;
		}

		return $ret;
	}
public static function decodePhpSerialize( $data ) {
		if ( !is_string( $data ) ) {
			throw new \InvalidArgumentException( '$data must be a string' );
		}

		$error = null;
		set_error_handler( function ( $errno, $errstr ) use ( &$error ) {
			$error = $errstr;
			return true;
		} );
		$ret = unserialize( $data );
		restore_error_handler();

		if ( $error !== null ) {
			self::$logger->error( 'PHP unserialization failed: ' . $error );
			return null;
		}

		// PHP strangely allows non-arrays to session_decode(), even though
		// that breaks $_SESSION. Let's not do that.
		if ( !is_array( $ret ) ) {
			self::$logger->error( 'PHP unserialization failed (value was not an array)' );
			return null;
		}

		return $ret;
	}
public static function decodePhpSerialize ( $ data ) { if ( ! is_string ( $ data ) ) { throw new \ InvalidArgumentException ( '$data must be a string' ) ; } $ error = null ; set_error_handler ( function ( $ errno , $ errstr ) use ( & $ error ) { $ error = $ errstr ; return true ; } ) ; $ ret = unserialize ( $ data ) ; restore_error_handler ( ) ; if ( $ error !== null ) { self :: $ logger -> error ( 'PHP unserialization failed: ' . $ error ) ; return null ; } // PHP strangely allows non-arrays to session_decode(), even though // that breaks $_SESSION. Let's not do that. if ( ! is_array ( $ ret ) ) { self :: $ logger -> error ( 'PHP unserialization failed (value was not an array)' ) ; return null ; } return $ ret ; }
Decode a session string in 'php_serialize' format to an array
@note Generally you'll use self::decode() instead of this method.
@param string $data Session data. Use the same caution in passing
user-controlled data here that you would to PHP's unserialize function.
@return array|null Data, or null on failure
@throws \\InvalidArgumentException
Decode a session string in php_serialize format to an array