Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UpdateEntityConfigMigration run into an infinite loop due to dependency-injection update #1116

Open
lccimat opened this issue Oct 23, 2024 · 0 comments
Assignees
Labels

Comments

@lccimat
Copy link

lccimat commented Oct 23, 2024

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 :

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 = [];
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants