Skip to content

Commit

Permalink
Merge pull request #11771 from doctrine/2.20.x-merge-up-into-2.21.x_3…
Browse files Browse the repository at this point in the history
…Yg2ZYgM

Merge release 2.20.1 into 2.21.x
  • Loading branch information
greg0ire authored Dec 19, 2024
2 parents 2b94ec1 + e3cabad commit e89b58a
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion .github/workflows/release-on-milestone-closed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions docs/en/reference/basic-mapping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,28 @@ 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
<?php
#[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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
18 changes: 18 additions & 0 deletions tests/Tests/ORM/Functional/ReadOnlyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e89b58a

Please sign in to comment.