diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 9fc2664859..efc722b135 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -24,4 +24,4 @@ on: jobs: coding-standards: - uses: "doctrine/.github/.github/workflows/coding-standards.yml@6.0.0" + uses: "doctrine/.github/.github/workflows/coding-standards.yml@7.1.0" diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 84bf616c87..58eb5f8145 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -17,4 +17,4 @@ on: jobs: documentation: name: "Documentation" - uses: "doctrine/.github/.github/workflows/documentation.yml@6.0.0" + uses: "doctrine/.github/.github/workflows/documentation.yml@7.1.0" diff --git a/.github/workflows/release-on-milestone-closed.yml b/.github/workflows/release-on-milestone-closed.yml index 0a35bee661..8ed48106ac 100644 --- a/.github/workflows/release-on-milestone-closed.yml +++ b/.github/workflows/release-on-milestone-closed.yml @@ -7,7 +7,7 @@ on: jobs: release: - uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@6.0.0" + uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@7.1.0" secrets: GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }} GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }} diff --git a/docs/en/reference/basic-mapping.rst b/docs/en/reference/basic-mapping.rst index 0c37867cff..55fe038937 100644 --- a/docs/en/reference/basic-mapping.rst +++ b/docs/en/reference/basic-mapping.rst @@ -167,6 +167,7 @@ Here is a complete list of ``Column``s attributes (all optional): - ``nullable`` (default: ``false``): Whether the column is nullable. - ``insertable`` (default: ``true``): Whether the column should be inserted. - ``updatable`` (default: ``true``): Whether the column should be updated. +- ``generated`` (default: ``null``): Whether the generated strategy should be ``'NEVER'``, ``'INSERT'`` and ``ALWAYS``. - ``enumType`` (requires PHP 8.1 and ``doctrine/orm`` 2.11): The PHP enum class name to convert the database value into. - ``precision`` (default: 0): The precision for a decimal (exact numeric) column (applies only for decimal column), diff --git a/docs/en/tutorials/override-field-association-mappings-in-subclasses.rst b/docs/en/tutorials/override-field-association-mappings-in-subclasses.rst index cd5e19cbd8..f81faba712 100644 --- a/docs/en/tutorials/override-field-association-mappings-in-subclasses.rst +++ b/docs/en/tutorials/override-field-association-mappings-in-subclasses.rst @@ -9,7 +9,7 @@ i.e. attributes and associations metadata in particular. The example here shows the overriding of a class that uses a trait but is similar when extending a base class as shown at the end of this tutorial. -Suppose we have a class ExampleEntityWithOverride. This class uses trait ExampleTrait: +Suppose we have a class ``ExampleEntityWithOverride``. This class uses trait ``ExampleTrait``: .. code-block:: php @@ -17,22 +17,20 @@ Suppose we have a class ExampleEntityWithOverride. This class uses trait Example #[Entity] #[AttributeOverrides([ - new AttributeOverride('foo', [ - 'column' => new Column([ - 'name' => 'foo_overridden', - 'type' => 'integer', - 'length' => 140, - 'nullable' => false, - 'unique' => false, - ]), - ]), + new AttributeOverride('foo', new Column( + name: 'foo_overridden', + type: 'integer', + length: 140, + nullable: false, + unique: false, + )), ])] #[AssociationOverrides([ new AssociationOverride('bar', [ - 'joinColumns' => new JoinColumn([ - 'name' => 'example_entity_overridden_bar_id', - 'referencedColumnName' => 'id', - ]), + new JoinColumn( + name: 'example_entity_overridden_bar_id', + referencedColumnName: 'id', + ), ]), ])] class ExampleEntityWithOverride @@ -47,7 +45,7 @@ Suppose we have a class ExampleEntityWithOverride. This class uses trait Example private $id; } -The docblock is showing metadata override of the attribute and association type. It +``#[AttributeOverrides]`` contains metadata override of the attribute and association type. It basically changes the names of the columns mapped for a property ``foo`` and for the association ``bar`` which relates to Bar class shown above. Here is the trait which has mapping metadata that is overridden by the attribute above: diff --git a/phpcs.xml.dist b/phpcs.xml.dist index b14bbc6c1d..34ecdf46af 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,5 +1,7 @@ - + diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php index 87b434994c..9d86c34dbd 100644 --- a/src/UnitOfWork.php +++ b/src/UnitOfWork.php @@ -2394,7 +2394,7 @@ public function createEntity(string $className, array $data, array &$hints = []) $oid = spl_object_id($entity); $this->registerManaged($entity, $id, $data); - if (isset($hints[Query::HINT_READ_ONLY])) { + if (isset($hints[Query::HINT_READ_ONLY]) && $hints[Query::HINT_READ_ONLY] === true) { $this->readOnlyObjects[$oid] = true; } } diff --git a/tests/Tests/ORM/Functional/ReadOnlyTest.php b/tests/Tests/ORM/Functional/ReadOnlyTest.php index f566b316ff..7a27a8b260 100644 --- a/tests/Tests/ORM/Functional/ReadOnlyTest.php +++ b/tests/Tests/ORM/Functional/ReadOnlyTest.php @@ -88,6 +88,24 @@ public function testReadOnlyQueryHint(): void self::assertTrue($this->_em->getUnitOfWork()->isReadOnly($user)); } + public function testNotReadOnlyQueryHint(): void + { + $user = new ReadOnlyEntity('beberlei', 1234); + + $this->_em->persist($user); + + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery('SELECT u FROM ' . ReadOnlyEntity::class . ' u WHERE u.id = ?1'); + $query->setParameter(1, $user->id); + $query->setHint(Query::HINT_READ_ONLY, false); + + $user = $query->getSingleResult(); + + self::assertFalse($this->_em->getUnitOfWork()->isReadOnly($user)); + } + public function testNotReadOnlyIfObjectWasProxyBefore(): void { $user = new ReadOnlyEntity('beberlei', 1234);