Skip to content

Commit 4ea88e2

Browse files
lucaswerkmeisterWMDE bot
authored andcommitted
EntityId: Soft-deprecate Serializable methods and stop using them
Most callers of serialize() should use getSerialization() instead (tests for the method specifically are left alone for now); unserialize() doesn’t even have any callers outside of its tests and __unserialize() ipmlementations. While it was never guaranteed that serialize() and getSerialization() return the same string, this is indeed the case for all EntityId classes I could find, and a lot of the callers were relying on it anyway. Bug: T345856 Change-Id: I64e2e54b344e8dd64078f81502d0d067f6ea3a5b
1 parent ff0bc18 commit 4ea88e2

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/Entity/EntityId.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ public function __toString();
3232
*/
3333
public function equals( $target );
3434

35+
/**
36+
* @see Serializable::serialize()
37+
* @return string|null
38+
* @deprecated Use {@link self::getSerialization()} instead.
39+
*/
40+
public function serialize();
41+
42+
/**
43+
* @see Serializable::unserialize()
44+
* @param string $data
45+
* @return void
46+
* @deprecated There should be no reason to use this.
47+
*/
48+
public function unserialize( $data );
49+
3550
/**
3651
* This method replaces {@link Serializable::serialize()}.
3752
* Do not call it manually.

src/Entity/EntityIdValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function getHash(): string {
3737
* @return string
3838
*/
3939
public function getSerializationForHash(): string {
40-
$data = $this->entityId->serialize();
40+
$data = $this->entityId->getSerialization();
4141
$innerSerialization = 'C:' . strlen( get_class( $this->entityId ) ) . ':"' . get_class( $this->entityId ) .
4242
'":' . strlen( $data ) . ':{' . $data . '}';
4343

0 commit comments

Comments
 (0)