Message: Throw if given invalid serialized data
authorBrad Jorsch <bjorsch@wikimedia.org>
Wed, 28 Nov 2018 15:25:01 +0000 (10:25 -0500)
committerBrad Jorsch <bjorsch@wikimedia.org>
Wed, 28 Nov 2018 15:28:34 +0000 (10:28 -0500)
Instead of silently winding up with a bogus Message object having most
fields invalidly set to null, just throw an exception.

Bug: T210528
Change-Id: I79313f8acf3ebb1ef12dac30c362aa10c715f40b

includes/Message.php

index 3bd7755..7dd22c7 100644 (file)
@@ -300,6 +300,10 @@ class Message implements MessageSpecifier, Serializable {
         */
        public function unserialize( $serialized ) {
                $data = unserialize( $serialized );
+               if ( !is_array( $data ) ) {
+                       throw new InvalidArgumentException( __METHOD__ . ': Invalid serialized data' );
+               }
+
                $this->interface = $data['interface'];
                $this->key = $data['key'];
                $this->keysToTry = $data['keysToTry'];