@@ -944,22 +944,15 @@ protected function addSearchCommandWhereClause($q, $filter): array
944944 case $ this ->translator ->trans ('mautic.lead.lead.searchcommand.dnc ' , [], null , 'en_US ' ):
945945 $ anyKeyword = $ this ->translator ->trans ('mautic.lead.lead.searchcommand.dnc.any ' );
946946 $ anyKeywordEn = $ this ->translator ->trans ('mautic.lead.lead.searchcommand.dnc.any ' , [], null , 'en_US ' );
947+ $ sq = $ this ->getEntityManager ()->getConnection ()->createQueryBuilder ();
948+ $ sq ->select ('1 ' )
949+ ->from (MAUTIC_TABLE_PREFIX . 'lead_donotcontact ' , 'dnc ' )
950+ ->where ($ q ->expr ()->eq ('l.id ' , 'dnc.lead_id ' ));
951+
947952 if ($ string === $ anyKeyword || $ string === $ anyKeywordEn ) {
948- $ sq = $ this ->getEntityManager ()->getConnection ()->createQueryBuilder ();
949- $ sq ->select ('1 ' )
950- ->from (MAUTIC_TABLE_PREFIX .'lead_donotcontact ' , 'dnc ' )
951- ->where ($ q ->expr ()->eq ('l.id ' , 'dnc.lead_id ' ));
952953 $ returnParameter = false ;
953954 } else {
954- $ sq = $ this ->getEntityManager ()->getConnection ()->createQueryBuilder ();
955- $ sq ->select ('1 ' )
956- ->from (MAUTIC_TABLE_PREFIX .'lead_donotcontact ' , 'dnc ' )
957- ->where (
958- $ q ->expr ()->and (
959- $ q ->expr ()->eq ('l.id ' , 'dnc.lead_id ' ),
960- $ q ->expr ()->eq ('dnc.channel ' , ": $ unique " )
961- )
962- );
955+ $ sq ->andWhere ($ q ->expr ()->eq ('dnc.channel ' , ": $ unique " ));
963956 $ returnParameter = true ;
964957 }
965958 $ expr = $ q ->expr ()->{$ filter ->not ? 'notExists ' : 'exists ' }($ sq ->getSQL ());
0 commit comments