From 15eeb8a4ce5be2dda2bf008cff8574ee137a2135 Mon Sep 17 00:00:00 2001 From: Gauthier Gilles Date: Thu, 21 Oct 2021 14:30:12 +0200 Subject: [PATCH 1/2] fix --- Event/Subscriber/DoctrineORMSubscriber.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Event/Subscriber/DoctrineORMSubscriber.php b/Event/Subscriber/DoctrineORMSubscriber.php index 3db9776..9e4d6ae 100644 --- a/Event/Subscriber/DoctrineORMSubscriber.php +++ b/Event/Subscriber/DoctrineORMSubscriber.php @@ -78,7 +78,7 @@ public function filterEntity(GetFilterConditionEvent $event) if ($dqlFrom = $event->getQueryBuilder()->getDQLPart('from')) { $rootPart = reset($dqlFrom); - $fieldName = ltrim($event->getField(), $rootPart->getAlias() . '.'); + $fieldName = preg_replace('/^'.$rootPart->getAlias().'\./', '', $event->getField()); $metadata = $queryBuilder->getEntityManager()->getClassMetadata($rootPart->getFrom()); if (isset($metadata->associationMappings[$fieldName]) && (!$metadata->associationMappings[$fieldName]['isOwningSide'] || $metadata->associationMappings[$fieldName]['type'] === ClassMetadataInfo::MANY_TO_MANY)) { From b41e448b97e2f4254d2c8a3c3e6179875ab64276 Mon Sep 17 00:00:00 2001 From: Gauthier Gilles Date: Thu, 21 Oct 2021 14:40:44 +0200 Subject: [PATCH 2/2] use substr --- Event/Subscriber/DoctrineORMSubscriber.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Event/Subscriber/DoctrineORMSubscriber.php b/Event/Subscriber/DoctrineORMSubscriber.php index 9e4d6ae..cb42cca 100644 --- a/Event/Subscriber/DoctrineORMSubscriber.php +++ b/Event/Subscriber/DoctrineORMSubscriber.php @@ -78,7 +78,7 @@ public function filterEntity(GetFilterConditionEvent $event) if ($dqlFrom = $event->getQueryBuilder()->getDQLPart('from')) { $rootPart = reset($dqlFrom); - $fieldName = preg_replace('/^'.$rootPart->getAlias().'\./', '', $event->getField()); + $fieldName = substr($event->getField(), strlen($rootPart->getAlias.'.')); $metadata = $queryBuilder->getEntityManager()->getClassMetadata($rootPart->getFrom()); if (isset($metadata->associationMappings[$fieldName]) && (!$metadata->associationMappings[$fieldName]['isOwningSide'] || $metadata->associationMappings[$fieldName]['type'] === ClassMetadataInfo::MANY_TO_MANY)) {