Skip to content

Merge 3.7.x up into 3.8.x - #12787

Merged
greg0ire merged 25 commits into
doctrine:3.8.xfrom
greg0ire:3.8.x
Nov 14, 2026
Merged

greg0ire merged 25 commits into
doctrine:3.8.xfrom
greg0ire:3.8.x

Conversation

@greg0ire

Copy link
Copy Markdown
Member

No description provided.

beberlei and others added 24 commits November 6, 2026 21:24
The queue of deferred postLoad invocations is shared on the UnitOfWork, so
any nested load finishing during an outer hydration fired postLoad for
entities the outer hydrator was still working on. Changes made by listeners
to collections were lost or items got duplicated.

Track the hydration depth in HydrationCompleteHandler, so that only the
outermost hydration fires the queue. Row-by-row hydration tracks each row
instead of the whole iteration, because control returns to user code on
every yield and generators may never finish. Query::toIterable() now fires
postLoad at the end of each row instead of after each alias of the row.

X-Coauthored-By: Claude Opus 5.5 <noreply@anthropic.com>
Leaving the outermost section now fires the queue, so callers no longer have
to remember a separate hydrationComplete() call.

AbstractHydrator::toIterable() always sets HINT_INTERNAL_ITERATION for that,
otherwise NativeQuery::toIterable() would fire postLoad for each row before
its eager collections are batch loaded at the end of the iteration. Those
collections are now loaded for each row, as with Query::toIterable(). This
also stops them from getting duplicate items when accessed in the loop.

X-Coauthored-By: Claude Opus 5.5 <noreply@anthropic.com>
…12707)

* Initialize a lazy embeddable before reading its properties

On PHP 8.4+, RawValuePropertyAccessor reads properties by casting the
object to an array, which does not initialize a lazy object. When an
embeddable is an uninitialized lazy object created in userland (e.g. by
symfony/object-mapper), every embedded column was read as null and the
entity was silently persisted with NULL values.

Embeddables are never Doctrine proxies, so initializing them before
reading their properties cannot trigger unwanted lazy loading of an
entity.

Fixes doctrine#12706

* Initialize a lazy embeddable before writing to it, but not inside a lazy entity

Writing into an uninitialized lazy embeddable without initializing it
first, as refresh() does, lets the initializer overwrite the written
values when the object is initialized later on, e.g. by the next flush.

Doctrine itself creates lazy embeddables for partial entities, whose
initializer loads the entity. They must not be initialized while the
entity is still uninitialized, neither when hydrating them nor when
reading them through the property accessor.

Document on PropertyAccessor that only the given object is guaranteed
not to be initialized.
Fixes doctrine#5633

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes doctrine#5658

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes doctrine#5707

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes doctrine#11668

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes doctrine#5968

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes doctrine#6597

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes doctrine#6661

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes doctrine#8514

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes doctrine#11107

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…revious elements

Fixes doctrine#7239

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes doctrine#7481

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes doctrine#7480

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes doctrine#8322

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes doctrine#8608

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes doctrine#11942

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes doctrine#5613

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-to-many

Addresses review feedback on doctrine#11107 and doctrine#7239.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Addresses review feedback on doctrine#7480.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-only-fixes

Documentation fixes for triaged issues
…postload

Defer postLoad until the outermost hydration has finished
# Conflicts:
#	docs/en/cookbook/working-with-datetime.rst
#	src/Internal/Hydration/AbstractHydrator.php
#	src/Internal/Hydration/SimpleObjectHydrator.php
@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Note

Greptile reviews are for Doctrine maintainers as a first filter, do not start fixing all the issues immediately unless you think they make sense. A maintainer will give you a green light on this PR for further development or rejection.

RetriggerView in GreptileConfidence Score: 4/5

[High impact] The changes reach shared entity-loading and lifecycle behavior across Doctrine ORM query paths.

This appears safe to merge, with one non-blocking documentation clarification.

Findings

  1. P2 Inverse-side replacements are not saved ▶

Summary

Merges fixes and documentation from 3.7.x into 3.8.x.

  • Nested loads finish before each result's postLoad listeners run.
  • Embedded fields initialize lazy values without waking partial entities.
  • The ORM guides now explain updated query, mapping, and lifecycle usage.

Reviews (1) · Last reviewed commit: "Merge remote-tracking branch 'origin/3.7..." · Reviewed by Greptile

Comment on lines +595 to +597
For many-to-many associations, replacing the collection only deletes the rows of the
join table, and the links of the new collection are inserted afterwards. The target
entities themselves are not deleted in this case.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Inverse-side replacements are not saved

This paragraph only holds for the owning side of a many-to-many association. Replacing an inverse-side collection alone leaves the database unchanged: ManyToManyPersister::delete() and update() both skip it. Readers following this advice would lose their changes on reload. Qualify the paragraph and tell readers to update the owning side too.

Suggested change
For many-to-many associations, replacing the collection only deletes the rows of the
join table, and the links of the new collection are inserted afterwards. The target
entities themselves are not deleted in this case.
For the owning side of many-to-many associations, replacing the collection only
deletes the rows of the join table, and the links of the new collection are inserted
afterwards. The target entities themselves are not deleted in this case.
Replacing an inverse-side collection alone does not change the database; update
the owning side too.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but this is a merge-up PR. I did not introduce this change.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s fair—this merge-up didn’t introduce the wording, so asking you to change it here is misplaced. The concern is about the resulting docs, but the fix belongs on the 3.7.x source change or in a follow-up, not this merge-up. I should have framed the comment as informational rather than as a requested change here.

@greg0ire
greg0ire merged commit 05a7170 into doctrine:3.8.x Nov 14, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants