Skip to content

Commit

Permalink
Merge pull request #11773 from doctrine/3.3.x-merge-up-into-3.4.x_xx7…
Browse files Browse the repository at this point in the history
…XyUCl

Merge release 3.3.1 into 3.4.x
  • Loading branch information
greg0ire authored Dec 19, 2024
2 parents a15543a + b1f8253 commit 8ebd98e
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 20 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
21 changes: 21 additions & 0 deletions .github/workflows/website-schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

name: "Website config validation"

on:
pull_request:
branches:
- "*.x"
paths:
- ".doctrine-project.json"
- ".github/workflows/website-schema.yml"
push:
branches:
- "*.x"
paths:
- ".doctrine-project.json"
- ".github/workflows/website-schema.yml"

jobs:
json-validate:
name: "Validate JSON schema"
uses: "doctrine/.github/.github/workflows/[email protected]"
1 change: 1 addition & 0 deletions docs/en/reference/basic-mapping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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),
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
4 changes: 3 additions & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0"?>
<ruleset>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
name="PHP_CodeSniffer"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
Expand Down
2 changes: 1 addition & 1 deletion src/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
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 @@ -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);
Expand Down

0 comments on commit 8ebd98e

Please sign in to comment.