Skip to content

Commit

Permalink
Deprecate SequenceGenerator implementing Serializable (#11468)
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus authored May 22, 2024
1 parent 0a177d5 commit ae659fe
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Upgrade to 3.2

## Deprecate remaining `Serializable` implementation

Relying on `SequenceGenerator` implementing the `Serializable` is deprecated
because that interface won't be implemented in ORM 4 anymore.

The following methods are deprecated:

* `SequenceGenerator::serialize()`
* `SequenceGenerator::unserialize()`

## `orm:schema-tool:update` option `--complete` is deprecated

That option behaves as a no-op, and is deprecated. It will be removed in 4.0.
Expand Down
19 changes: 19 additions & 0 deletions src/Id/SequenceGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Doctrine\ORM\Id;

use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection;
use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\EntityManagerInterface;
use Serializable;

Expand Down Expand Up @@ -65,8 +66,17 @@ public function getNextValue(): int
return $this->nextValue;
}

/** @deprecated without replacement. */
final public function serialize(): string
{
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/pull/11468',
'%s() is deprecated, use __serialize() instead. %s won\'t implement the Serializable interface anymore in ORM 4.',
__METHOD__,
self::class,
);

return serialize($this->__serialize());
}

Expand All @@ -79,8 +89,17 @@ public function __serialize(): array
];
}

/** @deprecated without replacement. */
final public function unserialize(string $serialized): void
{
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/pull/11468',
'%s() is deprecated, use __unserialize() instead. %s won\'t implement the Serializable interface anymore in ORM 4.',
__METHOD__,
self::class,
);

$this->__unserialize(unserialize($serialized));
}

Expand Down

0 comments on commit ae659fe

Please sign in to comment.