Merge "Remove pre PHP 7.4 serialize()/unserialize()"
This commit is contained in:
commit
8a6ab5bccd
12 changed files with 15 additions and 102 deletions
|
|
@ -135,10 +135,6 @@ trait ApiMessageTrait {
|
|||
$this->apiData = $data;
|
||||
}
|
||||
|
||||
public function serialize(): string {
|
||||
return serialize( $this->__serialize() );
|
||||
}
|
||||
|
||||
public function __serialize() {
|
||||
return [
|
||||
'parent' => parent::__serialize(),
|
||||
|
|
@ -147,10 +143,6 @@ trait ApiMessageTrait {
|
|||
];
|
||||
}
|
||||
|
||||
public function unserialize( $serialized ): void {
|
||||
$this->__unserialize( unserialize( $serialized ) );
|
||||
}
|
||||
|
||||
public function __unserialize( $data ) {
|
||||
parent::__unserialize( $data['parent'] );
|
||||
$this->apiCode = $data['apiCode'];
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ use MediaWiki\StubObject\StubUserLang;
|
|||
* @newable
|
||||
* @ingroup Language
|
||||
*/
|
||||
class Message implements MessageSpecifier, Serializable {
|
||||
class Message implements MessageSpecifier {
|
||||
/** Use message text as-is */
|
||||
public const FORMAT_PLAIN = 'plain';
|
||||
/** Use normal wikitext -> HTML parsing (the result will be wrapped in a block-level HTML tag) */
|
||||
|
|
@ -252,15 +252,6 @@ class Message implements MessageSpecifier, Serializable {
|
|||
$this->language = $language;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Serializable::serialize()
|
||||
* @since 1.26
|
||||
* @return string
|
||||
*/
|
||||
public function serialize(): string {
|
||||
return serialize( $this->__serialize() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Serializable::serialize()
|
||||
* @since 1.38
|
||||
|
|
@ -287,15 +278,6 @@ class Message implements MessageSpecifier, Serializable {
|
|||
/**
|
||||
* @see Serializable::unserialize()
|
||||
* @since 1.38
|
||||
* @param string $serialized
|
||||
*/
|
||||
public function unserialize( $serialized ): void {
|
||||
$this->__unserialize( unserialize( $serialized ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Serializable::unserialize()
|
||||
* @since 1.26
|
||||
* @param array $data
|
||||
*/
|
||||
public function __unserialize( $data ) {
|
||||
|
|
|
|||
|
|
@ -176,17 +176,6 @@ abstract class GenericArrayObject extends ArrayObject {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Serializable::serialize
|
||||
*
|
||||
* @since 1.20
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serialize(): string {
|
||||
return serialize( $this->__serialize() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Serializable::serialize
|
||||
*
|
||||
|
|
@ -214,17 +203,6 @@ abstract class GenericArrayObject extends ArrayObject {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Serializable::unserialize
|
||||
*
|
||||
* @since 1.20
|
||||
*
|
||||
* @param string $serialization
|
||||
*/
|
||||
public function unserialize( $serialization ): void {
|
||||
$this->__unserialize( unserialize( $serialization ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Serializable::unserialize
|
||||
*
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
*
|
||||
* @since 1.22
|
||||
*/
|
||||
class HashRing implements Serializable {
|
||||
class HashRing {
|
||||
/** @var string Hashing algorithm for hash() */
|
||||
protected $algo;
|
||||
/** @var int[] Non-empty (location => integer weight) */
|
||||
|
|
@ -438,10 +438,6 @@ class HashRing implements Serializable {
|
|||
return time();
|
||||
}
|
||||
|
||||
public function serialize(): string {
|
||||
return serialize( $this->__serialize() );
|
||||
}
|
||||
|
||||
public function __serialize() {
|
||||
return [
|
||||
'algorithm' => $this->algo,
|
||||
|
|
@ -450,13 +446,9 @@ class HashRing implements Serializable {
|
|||
];
|
||||
}
|
||||
|
||||
public function unserialize( $serialized ): void {
|
||||
$this->__unserialize( unserialize( $serialized ) );
|
||||
}
|
||||
|
||||
public function __unserialize( $data ) {
|
||||
if ( is_array( $data ) ) {
|
||||
$this->init( $data['locations'], $data['algorithm'], $data['ejections'] );
|
||||
$this->init( $data['locations'] ?? [], $data['algorithm'] ?? 'sha1', $data['ejections'] ?? [] );
|
||||
} else {
|
||||
throw new UnexpectedValueException( __METHOD__ . ": unable to decode JSON." );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ use Wikimedia\LightweightObjectStore\ExpirationAwareness;
|
|||
* @ingroup Cache
|
||||
* @since 1.23
|
||||
*/
|
||||
class MapCacheLRU implements ExpirationAwareness, Serializable {
|
||||
class MapCacheLRU implements ExpirationAwareness {
|
||||
/** @var array Map of (key => value) */
|
||||
private $cache = [];
|
||||
/** @var array Map of (key => (UNIX timestamp, (field => UNIX timestamp))) */
|
||||
|
|
@ -367,10 +367,6 @@ class MapCacheLRU implements ExpirationAwareness, Serializable {
|
|||
];
|
||||
}
|
||||
|
||||
public function serialize(): string {
|
||||
return serialize( $this->__serialize() );
|
||||
}
|
||||
|
||||
public function __unserialize( $data ) {
|
||||
$this->cache = $data['entries'] ?? [];
|
||||
$this->timestamps = $data['timestamps'] ?? [];
|
||||
|
|
@ -379,10 +375,6 @@ class MapCacheLRU implements ExpirationAwareness, Serializable {
|
|||
$this->epoch = $this->getCurrentTime();
|
||||
}
|
||||
|
||||
public function unserialize( $serialized ): void {
|
||||
$this->__unserialize( unserialize( $serialized ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float UNIX timestamp
|
||||
* @codeCoverageIgnore
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ use MediaWiki\Site\MediaWikiPageNameNormalizer;
|
|||
* @ingroup Site
|
||||
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
|
||||
*/
|
||||
class Site implements Serializable {
|
||||
class Site {
|
||||
public const TYPE_UNKNOWN = 'unknown';
|
||||
public const TYPE_MEDIAWIKI = 'mediawiki';
|
||||
|
||||
|
|
@ -651,17 +651,6 @@ class Site implements Serializable {
|
|||
return new Site();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Serializable::serialize
|
||||
*
|
||||
* @since 1.21
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serialize(): string {
|
||||
return serialize( $this->__serialize() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Serializable::serialize
|
||||
*
|
||||
|
|
@ -684,17 +673,6 @@ class Site implements Serializable {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Serializable::unserialize
|
||||
*
|
||||
* @since 1.21
|
||||
*
|
||||
* @param string $serialized
|
||||
*/
|
||||
public function unserialize( $serialized ): void {
|
||||
$this->__unserialize( unserialize( $serialized ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Serializable::unserialize
|
||||
*
|
||||
|
|
|
|||
|
|
@ -897,8 +897,8 @@ class MessageTest extends MediaWikiLangTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers Message::serialize
|
||||
* @covers Message::unserialize
|
||||
* @covers Message::__serialize
|
||||
* @covers Message::__unserialize
|
||||
*/
|
||||
public function testSerialization() {
|
||||
$msg = new Message( 'parentheses' );
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$name = $prop->getName();
|
||||
$usedMsg = ltrim( "$msg ($name)" );
|
||||
if ( $name === 'message' && $expected->message ) {
|
||||
$this->assertSame( $expected->message->serialize(), $actual->message->serialize(),
|
||||
$this->assertSame( $expected->message->__serialize(), $actual->message->__serialize(),
|
||||
$usedMsg );
|
||||
} else {
|
||||
$this->assertEquals( $expected->$name, $actual->$name, $usedMsg );
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ class SiteImporterTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
foreach ( $sites as $site ) {
|
||||
$key = $site->getGlobalId();
|
||||
$data = unserialize( $site->serialize() );
|
||||
$data = unserialize( serialize( $site ) );
|
||||
|
||||
$serialized[$key] = $data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,7 +209,8 @@ class SiteListTest extends MediaWikiIntegrationTestCase {
|
|||
*
|
||||
* @param SiteList $list
|
||||
* @covers SiteList::getSerializationData
|
||||
* @covers SiteList::unserialize
|
||||
* @covers SiteList::__serialize
|
||||
* @covers SiteList::__unserialize
|
||||
*/
|
||||
public function testSerialization( SiteList $list ) {
|
||||
$serialization = serialize( $list );
|
||||
|
|
|
|||
|
|
@ -284,12 +284,10 @@ class SiteTest extends MediaWikiIntegrationTestCase {
|
|||
/**
|
||||
* @dataProvider instanceProvider
|
||||
* @param Site $site
|
||||
* @covers Site::serialize
|
||||
* @covers Site::unserialize
|
||||
* @covers Site::__serialize
|
||||
* @covers Site::__unserialize
|
||||
*/
|
||||
public function testSerialization( Site $site ) {
|
||||
$this->assertInstanceOf( Serializable::class, $site );
|
||||
|
||||
$serialization = serialize( $site );
|
||||
$newInstance = unserialize( $serialization );
|
||||
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ class MapCacheLRUTest extends PHPUnit\Framework\TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers MapCacheLRU::serialize()
|
||||
* @covers MapCacheLRU::unserialize()
|
||||
* @covers MapCacheLRU::__serialize()
|
||||
* @covers MapCacheLRU::__unserialize()
|
||||
*/
|
||||
public function testSerialize() {
|
||||
$cache = new MapCacheLRU( 3 );
|
||||
|
|
|
|||
Loading…
Reference in a new issue