Relation many-to-one is not hydrated #7528

Open
opened 2026-01-22 15:52:58 +01:00 by admin · 0 comments
Owner

Originally created by @strauss69400 on GitHub (Jun 26, 2025).

Bug Report

Q A
Version 3.4
Previous Version if the bug is a regression 2.5

Summary

I am currently migrating an enterprise project from Symfony 3.4 with PHP 7.1 to Symfony 6.4 with PHP 8.2.
The application contains many EntityListeners.
Unfortunately, I’m encountering an issue with the hydration of ManyToOne properties.

Current behavior

I have an entity called "Mails" which contains a "opportunity" property.
In my MailsListener or inside an onFlush event, this property is properly hydrated.

Image

However, the "Opportunity" entity itself also has some ManyToOne relationships, which are not loaded.
For example, the "agent" property is not hydrated.

Image

Expected behavior

With the version 2.5 of Doctrine, The issue does not occur.

Image

How to reproduce

It’s enough to have a second-level entity and access it inside a listener like this:

$entity->getRelation()->getSubRelation();
or
$mail->getOpportunity()->getAgent();

Originally created by @strauss69400 on GitHub (Jun 26, 2025). ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |-------------------------------------------- | ------ | Version | 3.4 | Previous Version if the bug is a regression | 2.5 #### Summary I am currently migrating an enterprise project from Symfony 3.4 with PHP 7.1 to Symfony 6.4 with PHP 8.2. The application contains many EntityListeners. Unfortunately, I’m encountering an issue with the hydration of ManyToOne properties. #### Current behavior I have an entity called "Mails" which contains a "opportunity" property. In my MailsListener or inside an onFlush event, this property is properly hydrated. ![Image](https://github.com/user-attachments/assets/5637e186-2766-4e45-aa66-590b7bea8970) However, the "Opportunity" entity itself also has some ManyToOne relationships, which are not loaded. For example, the "agent" property is not hydrated. ![Image](https://github.com/user-attachments/assets/08ab9209-0835-4482-9682-7434991f157b) #### Expected behavior With the version 2.5 of Doctrine, The issue does not occur. ![Image](https://github.com/user-attachments/assets/5645a679-e292-4b1b-bc68-4d150c637af5) #### How to reproduce It’s enough to have a second-level entity and access it inside a listener like this: $entity->getRelation()->getSubRelation(); or $mail->getOpportunity()->getAgent();
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7528