diff --git a/Command/CustomDeduplicateCommand.php b/Command/CustomDeduplicateCommand.php index aa15ac1..a99302f 100644 --- a/Command/CustomDeduplicateCommand.php +++ b/Command/CustomDeduplicateCommand.php @@ -15,7 +15,6 @@ use Mautic\LeadBundle\Command\DeduplicateCommand; use Mautic\LeadBundle\Deduplicate\ContactDeduper; use Mautic\PluginBundle\Helper\IntegrationHelper; -use Mautic\UserBundle\Entity\User; use Mautic\UserBundle\Model\UserModel; use Monolog\Logger; use Symfony\Component\Console\Input\InputInterface; @@ -122,7 +121,6 @@ protected function execute(InputInterface $input, OutputInterface $output) } $notify = (bool) $input->getOption('notify'); - $key = __CLASS__; if (!$this->checkRunStatus($input, $output, $key)) { if ($notify) { diff --git a/Deduplicate/CustomDuplications.php b/Deduplicate/CustomDuplications.php index ec4e01c..0c215a6 100644 --- a/Deduplicate/CustomDuplications.php +++ b/Deduplicate/CustomDuplications.php @@ -87,11 +87,15 @@ private function getContactsByUniqueFields($uniqueFieldsWithData, $leadId = null $q = $this->entityManager->getConnection()->createQueryBuilder() ->select('l.*') ->from(MAUTIC_TABLE_PREFIX.'leads', 'l'); - // loop through the fields and foreach ($uniqueFieldsWithData as $col => $val) { - $q->andWhere("l.$col = :".$col) - ->setParameter($col, $val); + $q->andWhere( + $q->expr()->andX( + $q->expr()->eq('l.'.$col, ':'.$col), + $q->expr()->neq('l.'.$col, $q->expr()->literal('')), + $q->expr()->isNotNull('l.'.$col) + ) + )->setParameter($col, $val); } // if we have a lead ID lets use it @@ -114,7 +118,6 @@ private function getContactsByUniqueFields($uniqueFieldsWithData, $leadId = null $q->setMaxResults($limit); } $results = $q->execute()->fetchAll(); - // Collect the IDs $leads = []; foreach ($results as $r) { @@ -147,10 +150,6 @@ private function getCustomUniqueData(array $queryFields) $uniqueLeadFields = $this->fields->getCustomUniqueFields(); $uniqueLeadFieldData = []; foreach ($queryFields as $k => $v) { - // Don't use empty values when checking for duplicates - if (empty($v)) { - continue; - } if (in_array($k, $uniqueLeadFields)) { $uniqueLeadFieldData[$k] = $v; }