Description
Summary
MigrationContainer should not assume that symfony container services have been emptied.
A recent update of symfony/dependency-injection > Container::reset() method makes migrations run into an infinite reset loop.
see :
- [FrameworkBundle] Fix service reset between tests symfony/symfony#58240
- symfony/dependency-injection@23eb9f3
Steps to reproduce
- Git clone orocommerce-application on master
- run composer install
- run php bin/console oro:install
Installation runs into an infinite loop on first call to a migration implementing ResetContainerMigration (see ResetContainerMigrationListener::onPostUp()) : first migration called is UpdateEntityConfigMigration.
Actual Result
On instance of ResetContainerMigration call, ResetContainerMigrationListener calls $this->container->reset();
$this->container is the symfony container that iterates on every existing service that implements ResetInterface and call $service->reset(); on it.
Before symfony/dependency-injection 6.4.12 the Container::reset() method emptied services BEFORE calling "reset()" method on each services.
Since symfony/dependency-injection 6.4.12 the Container::reset() method empties services AFTER calling "reset()" method on each service.
As ResetContainerMigration is itself a service, symfony calls reset() also on ResetContainerMigration service instance and starts an infinite loop.
This ends with an complete memory consumption on my dev environment and out of mem in remote environments.
Expected Result
The loop is avoided and MigrationContainer does not causes infinite loop on reset();
Details about your environment
- OroPlatform version: dev-master (commit da48b87)
- PHP version: 8.3.12
- Database (PostgreSQL) 15 latest
Additional information
Previous symfony reset() method :
public function reset()
{
$services = $this->services + $this->privates;
$this->services = $this->factories = $this->privates = [];
foreach ($services as $service) {
try {
if ($service instanceof ResetInterface) {
$service->reset();
}
} catch (\Throwable) {
continue;
}
}
}
6.4.12 symfony reset() method :
public function reset()
{
$services = $this->services + $this->privates;
foreach ($services as $service) {
try {
if ($service instanceof ResetInterface) {
$service->reset();
}
} catch (\Throwable) {
continue;
}
}
$this->services = $this->factories = $this->privates = [];
}