tTableName(); $subscriberSegmentTable = $this->entityManager->getClassMetadata(SubscriberSegmentEntity::class)->getTableName(); $subscriberTable = $this->entityManager->getClassMetadata(SubscriberEntity::class)->getTableName(); $connection = $this->entityManager->getConnection(); $selectQueryBuilder = $connection->createQueryBuilder(); $selectQueryBuilder ->select('DISTINCT :task_id as task_id', 'subscribers.id as subscriber_id', ':processed as processed') ->from($subscriberSegmentTable, 'relation') ->join('relation', $subscriberTable, 'subscribers', 'subscribers.id = relation.subscriber_id') ->where('subscribers.deleted_at IS NULL') ->andWhere('subscribers.status = :subscribers_status') ->andWhere('relation.status = :relation_status') ->andWhere($selectQueryBuilder->expr()->in('relation.segment_id', ':segment_ids')) ->setParameter('task_id', $task->getId(), ParameterType::INTEGER) ->setParameter('processed', ScheduledTaskSubscriberEntity::STATUS_UNPROCESSED, ParameterType::INTEGER) ->setParameter('subscribers_status', SubscriberEntity::STATUS_SUBSCRIBED, ParameterType::STRING) ->setParameter('relation_status', SubscriberEntity::STATUS_SUBSCRIBED, ParameterType::STRING) ->setParameter('segment_ids', $segmentIds, Connection::PARAM_INT_ARRAY); if ($filterSegmentId) { $filterSegmentSubscriberIds = $this->segmentSubscriberRepository->findSubscribersIdsInSegment($filterSegmentId); $selectQueryBuilder ->andWhere($selectQueryBuilder->expr()->in('subscribers.id', ':filterSegmentSubscriberIds')) ->setParameter('filterSegmentSubscriberIds', $filterSegmentSubscriberIds, Connection::PARAM_INT_ARRAY); } // queryBuilder doesn't support INSERT IGNORE directly $sql = "INSERT IGNORE INTO $scheduledTaskSubscriberTable (task_id, subscriber_id, processed) " . $selectQueryBuilder->getSQL(); $result = $connection->executeQuery($sql, $selectQueryBuilder->getParameters(), $selectQueryBuilder->getParameterTypes()); return (int)$result->rowCount(); } /** * @param ScheduledTaskEntity $task * @param array $segmentIds * * @return int */ private function addSubscribersToTaskFromDynamicSegments(ScheduledTaskEntity $task, array $segmentIds, ?int $filterSegmentId = null) { $count = 0; foreach ($segmentIds as $segmentId) { $count += $this->addSubscribersToTaskFromDynamicSegment($task, (int)$segmentId, $filterSegmentId); } return $count; } private function addSubscribersToTaskFromDynamicSegment(ScheduledTaskEntity $task, int $segmentId, ?int $filterSegmentId) { $count = 0; $subscriberIds = $this->segmentSubscriberRepository->getSubscriberIdsInSegment($segmentId); if ($filterSegmentId) { $filterSegmentSubscriberIds = $this->segmentSubscriberRepository->getSubscriberIdsInSegment($filterSegmentId); $subscriberIds = array_intersect($subscriberIds, $filterSegmentSubscriberIds); } if ($subscriberIds) { $count += $this->addSubscribersToTaskByIds($task, $subscriberIds); } return $count; } private function addSubscribersToTaskByIds(ScheduledTaskEntity $task, array $subscriberIds) { $scheduledTaskSubscriberTable = $this->entityManager->getClassMetadata(ScheduledTaskSubscriberEntity::class)->getTableName(); $subscriberTable = $this->entityManager->getClassMetadata(SubscriberEntity::class)->getTableName(); $connection = $this->entityManager->getConnection(); $result = $connection->executeQuery( "INSERT IGNORE INTO $scheduledTaskSubscriberTable (task_id, subscriber_id, processed) SELECT DISTINCT ? as task_id, subscribers.`id` as subscriber_id, ? as processed FROM $subscriberTable subscribers WHERE subscribers.`deleted_at` IS NULL AND subscribers.`status` = ? AND subscribers.`id` IN (?)", [ $task->getId(), ScheduledTaskSubscriberEntity::STATUS_UNPROCESSED, SubscriberEntity::STATUS_SUBSCRIBED, $subscriberIds, ], [ ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING, Connection::PARAM_INT_ARRAY, ] ); return $result->rowCount(); } private function unique(array $subscriberIds) { $result = []; foreach ($subscriberIds as $id) { $result[$id] = $id; } return $result; } }
Fatal error: Uncaught Error: Class "MailPoet\Segments\SubscribersFinder" not found in /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php:4798 Stack trace: #0 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(5268): MailPoetGenerated\FreeCachedContainer->getSubscribersFinderService() #1 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2612): MailPoetGenerated\FreeCachedContainer->getSubscriberSubscribeControllerService() #2 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2640): MailPoetGenerated\FreeCachedContainer->getHooks2Service() #3 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(122): MailPoetGenerated\FreeCachedContainer->getInitializerService() #4 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(110): MailPoetVendor\Symfony\Component\DependencyInjection\Container->make('MailPoet\\Config...', 1) #5 /htdocs/wp-content/plugins/mailpoet/lib/DI/ContainerWrapper.php(39): MailPoetVendor\Symfony\Component\DependencyInjection\Container->get('MailPoet\\Config...') #6 /htdocs/wp-content/plugins/mailpoet/mailpoet_initializer.php(89): MailPoet\DI\ContainerWrapper->get('MailPoet\\Config...') #7 /htdocs/wp-content/plugins/mailpoet/mailpoet.php(194): require_once('/htdocs/wp-cont...') #8 /htdocs/wp-settings.php(526): include_once('/htdocs/wp-cont...') #9 /htdocs/wp-config.php(85): require_once('/htdocs/wp-sett...') #10 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #11 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #12 /htdocs/index.php(17): require('/htdocs/wp-blog...') #13 {main} thrown in /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php on line 4798