Repository navigation
Merge 3.7.x up into 3.8.x - #12787
Conversation
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
|
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.
[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
|
| 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. |
There was a problem hiding this comment.
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.
| 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. |
There was a problem hiding this comment.
Maybe, but this is a merge-up PR. I did not introduce this change.
There was a problem hiding this comment.
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.
No description provided.