Skip to content

Commit

Permalink
Merge "Revert "EntityId: Hard-deprecate Serializable methods""
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Sep 13, 2023
2 parents fecfd24 + c9c59ad commit 3a3a543
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 35 deletions.
3 changes: 1 addition & 2 deletions lib/packages/wikibase/data-model/RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* Removed support for calling `Statement::addNewReference()` and `StatementList` constructor with a
single array argument, which was deprecated in `Version 9.6.0 (2021-03-31)`. These should now be
called with a variadic argument list.
* Added `__serialize()` and `__unserialize()` methods to the `EntityId` interface,
and deprecated the `serialize()` and `unserialize()` methods.
* Added `__serialize()` and `__unserialize()` methods to the `EntityId` interface.
* Added native type hints to the `Statement` and `StatementList` classes
* Added `strict_types=1` to `Statement.php`, `StatementList.php`, and related test files
* Removed support for repository names in entity IDs (e.g. `foo:Q1234`)
Expand Down
2 changes: 0 additions & 2 deletions lib/packages/wikibase/data-model/src/Entity/ItemId.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public function __serialize(): array {
* @return string
*/
public function serialize() {
wfDeprecated( __METHOD__, '1.41' );
return $this->serialization;
}

Expand All @@ -85,7 +84,6 @@ public function __unserialize( array $data ): void {
* @param string $serialized
*/
public function unserialize( $serialized ) {
wfDeprecated( __METHOD__, '1.41' );
$array = json_decode( $serialized );
$this->serialization = is_array( $array ) ? $array[1] : $serialized;
$this->serialization = $this->serialization ?? '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public function __serialize(): array {
* @return string
*/
public function serialize() {
wfDeprecated( __METHOD__, '1.41' );
return $this->serialization;
}

Expand All @@ -79,7 +78,6 @@ public function __unserialize( array $data ): void {
* @param string $serialized
*/
public function unserialize( $serialized ) {
wfDeprecated( __METHOD__, '1.41' );
$array = json_decode( $serialized );
$this->serialization = is_array( $array ) ? $array[1] : $serialized;
$this->serialization = $this->serialization ?? '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Wikibase\DataModel\Tests\Entity;

use InvalidArgumentException;
use MediaWikiUnitTestCase;
use ReflectionClass;
use Wikibase\DataModel\Entity\EntityId;
use Wikibase\DataModel\Entity\ItemId;
Expand All @@ -22,7 +21,7 @@
* @author Jeroen De Dauw < [email protected] >
* @author John Erling Blad < [email protected] >
*/
class EntityIdTest extends MediaWikiUnitTestCase {
class EntityIdTest extends \PHPUnit\Framework\TestCase {

public static function instanceProvider() {
$ids = [];
Expand Down Expand Up @@ -74,9 +73,6 @@ public static function deserializationCompatibilityProvider(): array {
* @dataProvider deserializationCompatibilityProvider
*/
public function testDeserializationCompatibility( $expected, $serialization ) {
if ( str_starts_with( $serialization, 'C:' ) ) {
$this->expectDeprecationAndContinue( '/::unserialize/' );
}
$this->assertEquals(
$expected,
unserialize( $serialization )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Wikibase\DataModel\Tests\Entity;

use DataValues\IllegalValueException;
use MediaWikiUnitTestCase;
use Wikibase\DataModel\Entity\EntityId;
use Wikibase\DataModel\Entity\EntityIdValue;
use Wikibase\DataModel\Entity\ItemId;
Expand All @@ -21,7 +20,7 @@
* @author Thiemo Kreuz
* @author Daniel Kinzler
*/
class EntityIdValueTest extends MediaWikiUnitTestCase {
class EntityIdValueTest extends \PHPUnit\Framework\TestCase {

public function testCanConstruct() {
$entityId = new ItemId( 'Q123' );
Expand Down Expand Up @@ -161,9 +160,6 @@ public static function provideDeserializationCompatibility() {
* @param EntityIdValue $expected
*/
public function testDeserializationCompatibility( $serialized, EntityIdValue $expected ) {
if ( str_contains( $serialized, 'C:32:"Wikibase\DataModel\Entity\ItemId"' ) ) {
$this->expectDeprecationAndContinue( '/::unserialize/' );
}
$id = unserialize( $serialized );

$this->assertEquals( $expected, $id );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Wikibase\DataModel\Tests\Entity;

use InvalidArgumentException;
use MediaWikiUnitTestCase;
use Wikibase\DataModel\Entity\ItemId;

/**
Expand All @@ -15,7 +14,7 @@
* @license GPL-2.0-or-later
* @author Jeroen De Dauw < [email protected] >
*/
class ItemIdTest extends MediaWikiUnitTestCase {
class ItemIdTest extends \PHPUnit\Framework\TestCase {

/**
* @dataProvider idSerializationProvider
Expand Down Expand Up @@ -87,7 +86,6 @@ public function testGetEntityType() {

public function testSerialize() {
$id = new ItemId( 'Q1' );
$this->expectDeprecationAndContinue( '/ItemId::serialize/' );
$this->assertSame( 'Q1', $id->serialize() );
}

Expand All @@ -96,7 +94,6 @@ public function testSerialize() {
*/
public function testUnserialize( $json, $expected ) {
$id = new ItemId( 'Q1' );
$this->expectDeprecationAndContinue( '/ItemId::unserialize/' );
$id->unserialize( $json );
$this->assertSame( $expected, $id->getSerialization() );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Wikibase\DataModel\Tests\Entity;

use InvalidArgumentException;
use MediaWikiUnitTestCase;
use Wikibase\DataModel\Entity\NumericPropertyId;

/**
Expand All @@ -14,7 +13,7 @@
*
* @license GPL-2.0-or-later
*/
class NumericPropertyIdTest extends MediaWikiUnitTestCase {
class NumericPropertyIdTest extends \PHPUnit\Framework\TestCase {

/**
* @dataProvider idSerializationProvider
Expand Down Expand Up @@ -86,7 +85,6 @@ public function testGetEntityType() {

public function testSerialize() {
$id = new NumericPropertyId( 'P1' );
$this->expectDeprecationAndContinue( '/NumericPropertyId::serialize/' );
$this->assertSame( 'P1', $id->serialize() );
}

Expand All @@ -95,7 +93,6 @@ public function testSerialize() {
*/
public function testUnserialize( $json, $expected ) {
$id = new NumericPropertyId( 'P1' );
$this->expectDeprecationAndContinue( '/NumericPropertyId::unserialize/' );
$id->unserialize( $json );
$this->assertSame( $expected, $id->getSerialization() );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public function __construct( string $uriSerialization, string $remoteId ) {
}

public function serialize(): ?string {
wfDeprecated( __METHOD__, '1.41' );
return $this->serialization;
}

Expand All @@ -38,14 +37,12 @@ public function __serialize(): array {
}

public function unserialize( $serialization ): void {
wfDeprecated( __METHOD__, '1.41' );
$this->__unserialize( [ $serialization ] );
self::assertValidSerialization( $serialization );
$this->serialization = $serialization;
}

public function __unserialize( array $data ): void {
[ $serialization ] = $data;
self::assertValidSerialization( $serialization );
$this->serialization = $serialization;
$this->unserialize( $data[0] );
}

public function getEntityType(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
namespace Wikibase\Lib\Tests\FederatedProperties;

use InvalidArgumentException;
use MediaWikiTestCaseTrait;
use PHPUnit\Framework\TestCase;
use Wikibase\Lib\FederatedProperties\FederatedPropertyId;

Expand All @@ -15,12 +14,9 @@
*/
class FederatedPropertyIdTest extends TestCase {

use MediaWikiTestCaseTrait;

public function testCreateAndSerializeId() {
$serialization = 'http://www.wikidata.org/entity/P31';
$id = new FederatedPropertyId( $serialization, 'P31' );
$this->expectDeprecationAndContinue( '/FederatedPropertyId::serialize/' );
$this->assertEquals( $serialization, $id->serialize() );
$this->assertEquals( $serialization, $id->getSerialization() );
}
Expand All @@ -40,7 +36,6 @@ public function testCreationFailsIfURIhasNoPath() {
public function testUnserializationWithValidSerialization() {
$serialization = 'http://www.wikidata.org/entity/P32';
$id = new FederatedPropertyId( 'http://www.wikidata.org/entity/P31', 'P31' );
$this->expectDeprecationAndContinue( '/FederatedPropertyId::unserialize/' );
$id->unserialize( $serialization );
$this->assertEquals( $serialization, $id->getSerialization() );
}
Expand Down

0 comments on commit 3a3a543

Please sign in to comment.