From 991c0e99239e4fbedb1a705b879e652c88c00e12 Mon Sep 17 00:00:00 2001 From: Augustas Nedzinskas Date: Tue, 18 Jun 2024 15:18:06 +0200 Subject: [PATCH] fix: rebuilding DI container when it was already built during same request --- common/oatbox/service/ServiceManager.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/oatbox/service/ServiceManager.php b/common/oatbox/service/ServiceManager.php index 5d3a414a4..062fd08ae 100644 --- a/common/oatbox/service/ServiceManager.php +++ b/common/oatbox/service/ServiceManager.php @@ -267,7 +267,11 @@ public function getContainer(): ContainerInterface public function rebuildContainer(): void { + // if container was already built on same request, it has to be restarted before rebuild + // to avoid fatal error of compiled container modification + $this->containerStarter = null; $this->getContainerStarter()->getContainerBuilder()->forceBuild(); + // after container rebuild this cached starter needs a reset, to avoid using container already cached in memory $this->containerStarter = null; }