-
-
Notifications
You must be signed in to change notification settings - Fork 464
Description
Bug Report
Q | A |
---|---|
Version | 2.15.1 |
Symfony version ✅ | 7.1.1 |
Symfony version ❌ | 7.1.2 |
Summary
After upgrading Symfony from 7.1.0
to latest, plain cache:clear
started giving an error:
In HydratorException.php line 23:
You must configure a hydrator directory. See docs for details.
When I checked the generated Container file, the whole configuration section of the getDoctrineMongodb_Odm_DefaultDocumentManagerService
was missing (screenshot below shows the correct, working state; in the broken, there is no config). That's why this error is thrown - there really was no configuration made in the container:

I have traced the issue back to this exact commit and line in Symfony: symfony/symfony@d4b812c#diff-2a36924e0448b459f1261198e19953b5a8f143a591a7298c18f0bb47ba04b6bbL134. Adding back the line of
ksort($services);
Into the ServiceLocatorTagPass
fixed the issue. Then I dug deeper and found out, that the ksort
addition is really only needed when a particular set of services is being processed there. In my case, it was these services, in this order:
doctrine.orm.messenger.doctrine_schema_listener
doctrine.orm.listeners.doctrine_dbal_cache_adapter_schema_listener
doctrine.orm.listeners.doctrine_token_provider_schema_listener
doctrine.orm.listeners.pdo_session_handler_schema_listener
doctrine.orm.listeners.lock_store_schema_listener
doctrine.orm.default_listeners.attach_entity_listeners
Through more testing, I found out that the relative order of these two services is important:
doctrine.orm.messenger.doctrine_schema_listener
doctrine.orm.listeners.pdo_session_handler_schema_listener
This order does not work, but if the doctrine_schema_listener
comes after the other, then things start working. Coincidentally, due to the alphabetical ordering of the (now-removed) ksort()
method, this is exactly what was happening - the order of these two got flipped by sheer luck.
To verify this, I went to the service definition file messenger.xml
and adjusted the priorities as:
<service id="doctrine.orm.messenger.doctrine_schema_listener" class="Symfony\Bridge\Doctrine\SchemaListener\MessengerTransportDoctrineSchemaListener">
<argument type="tagged_iterator" tag="messenger.receiver" />
<tag name="doctrine.event_listener" event="postGenerateSchema" priority="-1" />
<tag name="doctrine.event_listener" event="onSchemaCreateTable" priority="-1" />
</service>
After this change, the error went away and the container built correctly. Unfortunately, I don't know enough about Doctrine to be able to tell why, or whether that is the correct fix to make. As a temporary solution to allow us to proceed with the upgrade, I implemented a custom Symfony compiler pass that assigns these new priorities from our code.
I assume this may be affected by something else in our environment, as this probably works well for many other people, since I could not find nearly anything with this error on the internet. I have no idea how to build a reproducer for this. This is in a massive monolith project 10+ years old.
Current behavior
With Symfony 7.1.2+ container build fails.
Expected behavior
It should not fail.