From a5c80a4c753454a1957683c4e9e8f3cec8998a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 7 Dec 2024 23:21:04 +0100 Subject: [PATCH 1/5] Provide XSD for phpcs file (#11752) It unlocks autocompletion and validation in some IDEs. --- phpcs.xml.dist | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index fa28a585b6..ec9ff9f2cc 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,5 +1,7 @@ - + From 95b0f5c328f890c7a2b40de7765bceead9837a30 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Thu, 26 Sep 2024 16:19:34 +0200 Subject: [PATCH 2/5] Add missing generated option --- docs/en/reference/basic-mapping.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/reference/basic-mapping.rst b/docs/en/reference/basic-mapping.rst index 32f8626806..0070c27176 100644 --- a/docs/en/reference/basic-mapping.rst +++ b/docs/en/reference/basic-mapping.rst @@ -239,6 +239,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), From 66f654d4e270fbb8f7c70bdb73b48dad806dda31 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 06:51:45 +0000 Subject: [PATCH 3/5] Bump doctrine/.github from 6.0.0 to 7.1.0 Bumps [doctrine/.github](https://github.com/doctrine/.github) from 6.0.0 to 7.1.0. - [Release notes](https://github.com/doctrine/.github/releases) - [Commits](https://github.com/doctrine/.github/compare/6.0.0...7.1.0) --- updated-dependencies: - dependency-name: doctrine/.github dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/coding-standards.yml | 2 +- .github/workflows/documentation.yml | 2 +- .github/workflows/release-on-milestone-closed.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 }} From 4a9101f383e9f5d19f7d65cc6d4ad3b77c031f7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bret=C3=A9ch=C3=A9?= Date: Mon, 16 Dec 2024 17:20:46 +0100 Subject: [PATCH 4/5] Check hint value before considering instance read-only This fixes a bug that occurs when calling setHint(Query::HINT_READ_ONLY, false) from a query object. UnitOfWork checks if this hint exists without considering the value passed as second argument. Handling the second parameter improves consistency with documentation. https://www.doctrine-project.org/projects/doctrine-orm/en/2.20/reference/improving-performance.html#read-only-entities --- src/UnitOfWork.php | 2 +- tests/Tests/ORM/Functional/ReadOnlyTest.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php index 73aae2f362..ff30f14f6d 100644 --- a/src/UnitOfWork.php +++ b/src/UnitOfWork.php @@ -2968,7 +2968,7 @@ public function createEntity($className, array $data, &$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 4d06e107d0..297c2d5a3e 100644 --- a/tests/Tests/ORM/Functional/ReadOnlyTest.php +++ b/tests/Tests/ORM/Functional/ReadOnlyTest.php @@ -90,6 +90,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); From 9402f9e0f79f32cf501bd107201e6dfbf4dd8317 Mon Sep 17 00:00:00 2001 From: HypeMC <2445045+HypeMC@users.noreply.github.com> Date: Wed, 18 Dec 2024 20:41:44 +0100 Subject: [PATCH 5/5] Fix docs examples for mappings overrides (#11770) --- ...eld-association-mappings-in-subclasses.rst | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) 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 0488c25e46..b7f74adf38 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: