Skip to content

Commit 999caa1

Browse files
caseylockerclaude
andcommitted
fix(promo-codes): address Codex review on discover query split
- Switch INSTANCE OF from :param binding to inline class interpolation, matching the original code's pattern and avoiding Doctrine discriminator binding edge cases - Add explicit parentheses around isLive DQL condition for defensive clarity (andWhere already wraps, but now consistent with email-linked) - Fix member email fallback: PHP empty() matches both NULL and '', but DQL only checked IS NULL — now also checks e.email = '' to match MemberPromoCodeTrait::getEmail() exactly Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4db6055 commit 999caa1

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

app/Repositories/Summit/DoctrineSummitRegistrationPromoCodeRepository.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -686,22 +686,20 @@ public function getDomainAuthorizedDiscoverableForSummit(Summit $summit, string
686686
{
687687
$em = $this->getEntityManager();
688688
$now = new \DateTime('now', new \DateTimeZone('UTC'));
689+
$daPromoClass = DomainAuthorizedSummitRegistrationPromoCode::class;
690+
$daDiscountClass = DomainAuthorizedSummitRegistrationDiscountCode::class;
689691

690692
$qb = $em->createQueryBuilder();
691693
$qb->select('e')
692694
->from($this->getBaseEntity(), 'e')
693695
->join('e.summit', 's')
694696
->where('s.id = :summit_id')
697+
->andWhere("(e INSTANCE OF {$daPromoClass} OR e INSTANCE OF {$daDiscountClass})")
695698
->andWhere(
696-
'(e INSTANCE OF :da_promo OR e INSTANCE OF :da_discount)'
697-
)
698-
->andWhere(
699-
'e.valid_since_date IS NULL OR e.valid_until_date IS NULL '
700-
. 'OR (:now >= e.valid_since_date AND :now <= e.valid_until_date)'
699+
'(e.valid_since_date IS NULL OR e.valid_until_date IS NULL '
700+
. 'OR (:now >= e.valid_since_date AND :now <= e.valid_until_date))'
701701
)
702702
->setParameter('summit_id', $summit->getId())
703-
->setParameter('da_promo', DomainAuthorizedSummitRegistrationPromoCode::class)
704-
->setParameter('da_discount', DomainAuthorizedSummitRegistrationDiscountCode::class)
705703
->setParameter('now', $now);
706704

707705
$candidates = $qb->getQuery()->getResult();
@@ -737,10 +735,11 @@ public function getEmailLinkedDiscoverableForSummit(Summit $summit, string $emai
737735
->join('e.summit', 's')
738736
->leftJoin('e.owner', 'o')
739737
->where('s.id = :summit_id')
740-
->andWhere('LOWER(e.email) = :email OR (e.email IS NULL AND LOWER(o.email) = :email)')
738+
->andWhere('LOWER(e.email) = :email OR ((e.email IS NULL OR e.email = :empty) AND LOWER(o.email) = :email)')
741739
->andWhere($isLiveDql)
742740
->setParameter('summit_id', $summitId)
743741
->setParameter('email', $email)
742+
->setParameter('empty', '')
744743
->setParameter('now', $now)
745744
->getQuery()->getResult();
746745

@@ -751,10 +750,11 @@ public function getEmailLinkedDiscoverableForSummit(Summit $summit, string $emai
751750
->join('e.summit', 's')
752751
->leftJoin('e.owner', 'o')
753752
->where('s.id = :summit_id')
754-
->andWhere('LOWER(e.email) = :email OR (e.email IS NULL AND LOWER(o.email) = :email)')
753+
->andWhere('LOWER(e.email) = :email OR ((e.email IS NULL OR e.email = :empty) AND LOWER(o.email) = :email)')
755754
->andWhere($isLiveDql)
756755
->setParameter('summit_id', $summitId)
757756
->setParameter('email', $email)
757+
->setParameter('empty', '')
758758
->setParameter('now', $now)
759759
->getQuery()->getResult();
760760

0 commit comments

Comments
 (0)