From 324fb908c7bb741f1efc35b3fd11e076ba6b805d Mon Sep 17 00:00:00 2001 From: Ralf Kuehnel Date: Tue, 21 Jul 2026 08:32:06 +0200 Subject: [PATCH 1/2] pass tenant when resolving connection factory --- .../MultiTenant/HeaderBasedMultiTenantConnectionFactory.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/Dbal/src/MultiTenant/HeaderBasedMultiTenantConnectionFactory.php b/packages/Dbal/src/MultiTenant/HeaderBasedMultiTenantConnectionFactory.php index 631719a7b..66d0e3c85 100644 --- a/packages/Dbal/src/MultiTenant/HeaderBasedMultiTenantConnectionFactory.php +++ b/packages/Dbal/src/MultiTenant/HeaderBasedMultiTenantConnectionFactory.php @@ -68,7 +68,7 @@ public function getManager(?string $tenant = null): ObjectManager Assert::notNull($connectionReference, "Lack of context about tenant in Message Headers. Please add `{$this->tenantHeaderName}` header metadata to your message."); } - $connectionFactory = $this->getConnectionFactory(); + $connectionFactory = $this->getConnectionFactory($tenant); Assert::isTrue($connectionFactory instanceof EcotoneManagerRegistryConnectionFactory, 'Connection factory was not registered by `DbalConnection::createForManagerRegistry()`'); /** @var ManagerRegistry $managerRegistry */ @@ -94,9 +94,9 @@ public function getConnection(?string $tenant = null): Connection return $dbalConnection->getDbalConnection(); } - public function getConnectionFactory(): ConnectionFactory + public function getConnectionFactory(?string $tenant = null): ConnectionFactory { - $connectionReference = $this->getCurrentConnectionReferenceOrNull(); + $connectionReference = $this->getCurrentConnectionReferenceOrNull($tenant); if ($connectionReference === null) { $tenant = $this->getCurrentTenantOrNull(); From 09e6357e7fb3776848828bc28bae4368bc77ef57 Mon Sep 17 00:00:00 2001 From: Ralf Kuehnel Date: Tue, 21 Jul 2026 08:44:39 +0200 Subject: [PATCH 2/2] preserve tenant in connection factory errors --- .../MultiTenant/HeaderBasedMultiTenantConnectionFactory.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/Dbal/src/MultiTenant/HeaderBasedMultiTenantConnectionFactory.php b/packages/Dbal/src/MultiTenant/HeaderBasedMultiTenantConnectionFactory.php index 66d0e3c85..3da045c26 100644 --- a/packages/Dbal/src/MultiTenant/HeaderBasedMultiTenantConnectionFactory.php +++ b/packages/Dbal/src/MultiTenant/HeaderBasedMultiTenantConnectionFactory.php @@ -99,12 +99,12 @@ public function getConnectionFactory(?string $tenant = null): ConnectionFactory $connectionReference = $this->getCurrentConnectionReferenceOrNull($tenant); if ($connectionReference === null) { - $tenant = $this->getCurrentTenantOrNull(); + $resolvedTenant = $tenant ?? $this->getCurrentTenantOrNull(); - if ($tenant === null) { + if ($resolvedTenant === null) { throw new InvalidArgumentException("Lack of context about tenant in Message Headers. Please add `{$this->tenantHeaderName}` header metadata to your message."); } else { - throw new InvalidArgumentException("Lack of mapping for tenant `{$tenant}`. Please provide mapping for this tenant or default connection name."); + throw new InvalidArgumentException("Lack of mapping for tenant `{$resolvedTenant}`. Please provide mapping for this tenant or default connection name."); } }