Compare commits

...

6 Commits
2.9.4 ... 2.9.5

Author SHA1 Message Date
Grégoire Paris
77cc86ed88 Merge pull request #8916 from greg0ire/failing-test-8914
Check current class' discriminator map
2021-08-23 12:20:22 +02:00
Grégoire Paris
1de28c2cab Merge pull request #8930 from doctrine/2.10-readme
Introduce 2.10 to readme
2021-08-21 16:05:17 +02:00
Claudio Zizza
565987f583 Introduce 2.10 to readme 2021-08-20 21:14:25 +02:00
Grégoire Paris
ae10af0259 Check current class' discriminator map
A class can be in its own discriminator map, as described in the
documentation example at
https://www.doctrine-project.org/projects/doctrine-orm/en/2.9/reference/inheritance-mapping.html#single-table-inheritance
Checking only the current class' discriminator map should be enough,
since it is set to a copy of its parent's discriminator map earlier.

Fixes #8914
2021-08-15 11:59:11 +02:00
Grégoire Paris
d636d79686 Merge pull request #8895 from derrabus/bugfix/serializable
Implement __serialize() and __unserialize()
2021-08-15 11:56:49 +02:00
Alexander M. Turek
ae4bcd61ee Implement __serialize() and __unserialize()
Signed-off-by: Alexander M. Turek <me@derrabus.de>
2021-08-08 01:24:06 +02:00
4 changed files with 90 additions and 17 deletions

View File

@@ -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
@@ -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

View File

@@ -103,27 +103,43 @@ class SequenceGenerator extends AbstractIdGenerator implements Serializable
/**
* @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'];
}
}

View File

@@ -285,7 +285,10 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
}
} else {
assert($parent instanceof ClassMetadataInfo); // https://github.com/doctrine/orm/issues/8746
if ((! $class->reflClass || ! $class->reflClass->isAbstract()) && ! in_array($class->name, $parent->discriminatorMap)) {
if (
(! $class->reflClass || ! $class->reflClass->isAbstract())
&& ! in_array($class->name, $class->discriminatorMap)
) {
throw MappingException::mappedClassNotPartOfDiscriminatorMap($class->name, $class->rootEntityName);
}
}

View File

@@ -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
{
}