Skip to content

Commit

Permalink
Merge tag '2.9.5' into 2.9.x-merge-up-into-2.10.x_Ryg07QLG
Browse files Browse the repository at this point in the history
2.9.x bugfix release (patch)

- Total issues resolved: **0**
- Total pull requests resolved: **2**
- Total contributors: **2**

 - [8930: Introduce 2.10 to readme](#8930) thanks to @SenseException

 - [8895: Implement __serialize() and __unserialize()](#8895) thanks to @derrabus
  • Loading branch information
greg0ire committed Aug 23, 2021
2 parents 627113d + 77cc86e commit 4f9c104
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 17 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
| [3.0.x][3.0] | [2.9.x][2.9] | [2.8.x][2.8] |
| [3.0.x][3.0] | [2.10.x][2.10] | [2.9.x][2.9] |
|:----------------:|:----------------:|:----------:|
| [![Build status][3.0 image]][3.0] | [![Build status][2.9 image]][2.9] | [![Build status][2.8 image]][2.8] |
| [![Coverage Status][3.0 coverage image]][3.0 coverage]| [![Coverage Status][2.9 coverage image]][2.9 coverage] | [![Coverage Status][2.8 coverage image]][2.8 coverage] |
| [![Build status][3.0 image]][3.0] | [![Build status][2.10 image]][2.10] | [![Build status][2.9 image]][2.9] |
| [![Coverage Status][3.0 coverage image]][3.0 coverage]| [![Coverage Status][2.10 coverage image]][2.10 coverage] | [![Coverage Status][2.9 coverage image]][2.9 coverage] |

Doctrine 2 is an object-relational mapper (ORM) for PHP 7.1+ that provides transparent persistence
for PHP objects. It sits on top of a powerful database abstraction layer (DBAL). One of its key features
Expand All @@ -24,7 +24,7 @@ without requiring unnecessary code duplication.
[2.9]: https://github.com/doctrine/orm/tree/2.9.x
[2.9 coverage image]: https://codecov.io/gh/doctrine/orm/branch/2.9.x/graph/badge.svg
[2.9 coverage]: https://codecov.io/gh/doctrine/orm/branch/2.9.x
[2.8 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg
[2.8]: https://github.com/doctrine/orm/tree/2.8
[2.8 coverage image]: https://codecov.io/gh/doctrine/orm/branch/2.8.x/graph/badge.svg
[2.8 coverage]: https://codecov.io/gh/doctrine/orm/branch/2.8.x
[2.10 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=2.10.x
[2.10]: https://github.com/doctrine/orm/tree/2.10.x
[2.10 coverage image]: https://codecov.io/gh/doctrine/orm/branch/2.10.x/graph/badge.svg
[2.10 coverage]: https://codecov.io/gh/doctrine/orm/branch/2.10.x
34 changes: 25 additions & 9 deletions lib/Doctrine/ORM/Id/SequenceGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,43 @@ public function getNextValue()

/**
* @return string
*
* @final
*/
public function serialize()
{
return serialize(
[
'allocationSize' => $this->_allocationSize,
'sequenceName' => $this->_sequenceName,
]
);
return serialize($this->__serialize());
}

/**
* @return array<string, mixed>
*/
public function __serialize(): array
{
return [
'allocationSize' => $this->_allocationSize,
'sequenceName' => $this->_sequenceName,
];
}

/**
* @param string $serialized
*
* @return void
*
* @final
*/
public function unserialize($serialized)
{
$array = unserialize($serialized);
$this->__unserialize(unserialize($serialized));
}

$this->_sequenceName = $array['sequenceName'];
$this->_allocationSize = $array['allocationSize'];
/**
* @param array<string, mixed> $data
*/
public function __unserialize(array $data): void
{
$this->_sequenceName = $data['sequenceName'];
$this->_allocationSize = $data['allocationSize'];
}
}
5 changes: 4 additions & 1 deletion lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,10 @@ protected function validateRuntimeMetadata($class, $parent)
}
} else {
assert($parent instanceof ClassMetadataInfo); // https://github.com/doctrine/orm/issues/8746
if ((! $class->reflClass || ! $class->reflClass->isAbstract()) && ! in_array($class->name, $parent->discriminatorMap, true)) {
if (
(! $class->reflClass || ! $class->reflClass->isAbstract())
&& ! in_array($class->name, $class->discriminatorMap, true)
) {
throw MappingException::mappedClassNotPartOfDiscriminatorMap($class->name, $class->rootEntityName);
}
}
Expand Down
54 changes: 54 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/GH8914Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

declare(strict_types=1);

namespace Doctrine\Tests\ORM\Functional\Ticket;

use Doctrine\Tests\OrmTestCase;

use function assert;
use function count;

final class GH8914Test extends OrmTestCase
{
/**
* @group GH-8914
* @doesNotPerformAssertions
*/
public function testDiscriminatorMapWithSeveralLevelsIsSupported(): void
{
$entityManager = $this->getTestEntityManager();
$entityManager->getClassMetadata(GH8914Person::class);
}
}

/**
* @MappedSuperclass
*/
abstract class GH8914BaseEntity
{
}

/**
* @Entity
* @InheritanceType("SINGLE_TABLE")
* @DiscriminatorColumn(name="discr", type="string")
* @DiscriminatorMap({"person" = "GH8914Person", "employee" = "GH8914Employee"})
*/
class GH8914Person extends GH8914BaseEntity
{
/**
* @var int
* @Id
* @Column(type="integer")
* @GeneratedValue
*/
public $id;
}

/**
* @Entity
*/
class GH8914Employee extends GH8914Person
{
}

0 comments on commit 4f9c104

Please sign in to comment.