Make WordPress Core

Ticket #17375: 17375.5.patch

File 17375.5.patch, 1.6 KB (added by channeleaton, 10 years ago)

Only adds checks for "C"key. Includes unit test.

  • src/wp-includes/functions.php

     
    327327                        }
    328328                        // or else fall through
    329329                case 'a' :
     330                case 'C' :
    330331                case 'O' :
    331                         return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data );
     332                        return (bool) preg_match( "/^{$token}:[+]?[0-9]+:/s", $data );
    332333                case 'b' :
    333334                case 'i' :
    334335                case 'd' :
  • tests/phpunit/includes/functions.php

     
    102102                        echo "\t $k : $v\n";
    103103                }
    104104        }
     105}
     106
     107class Serialized_Class implements Serializable {
     108
     109        public $data = array(
     110                'one',
     111                'two',
     112                'three',
     113        );
     114
     115        public function serialize() {
     116                return serialize($this->data);
     117        }
     118
     119        public function unserialize( $serialized ) {}
     120
    105121}
     122 No newline at end of file
  • tests/phpunit/tests/functions.php

     
    158158                        serialize("a\nb"),
    159159                        serialize(array()),
    160160                        serialize(array(1,1,2,3,5,8,13)),
    161                         serialize( (object)array('test' => true, '3', 4) )
     161                        serialize( (object)array('test' => true, '3', 4) ),
     162                        serialize( new Serialized_Class() )
    162163                );
    163164                foreach ( $cases as $case )
    164165                        $this->assertTrue( is_serialized($case), "Serialized data: $case" );