ubscribersForBounceWorker(ScheduledTaskEntity $scheduledTaskEntity): void { $scheduledTaskSubscribersTable = $this->entityManager->getClassMetadata(ScheduledTaskSubscriberEntity::class)->getTableName(); $subscribersTable = $this->entityManager->getClassMetadata(SubscriberEntity::class)->getTableName(); $stmt = $this->entityManager->getConnection()->prepare(" INSERT IGNORE INTO " . $scheduledTaskSubscribersTable . " (task_id, subscriber_id, processed) SELECT :taskId AS task_id, s.`id` AS subscriber_id, :unprocessed AS processed FROM " . $subscribersTable . " s WHERE s.`deleted_at` IS NULL AND s.`status` IN (:subscribed, :unconfirmed) "); $stmt->bindValue('taskId', $scheduledTaskEntity->getId()); $stmt->bindValue('unprocessed', ScheduledTaskSubscriberEntity::STATUS_UNPROCESSED); $stmt->bindValue('subscribed', SubscriberEntity::STATUS_SUBSCRIBED); $stmt->bindValue('unconfirmed', SubscriberEntity::STATUS_UNCONFIRMED); $stmt->executeQuery(); } /** @param int[] $ids */ public function deleteByTaskIds(array $ids): void { $this->entityManager->createQueryBuilder() ->delete(ScheduledTaskSubscriberEntity::class, 'sts') ->where('sts.task IN (:taskIds)') ->setParameter('taskIds', $ids) ->getQuery() ->execute(); // delete was done via DQL, make sure the entities are also detached from the entity manager $this->detachAll(function (ScheduledTaskSubscriberEntity $entity) use ($ids) { $task = $entity->getTask(); return $task && in_array($task->getId(), $ids, true); }); } public function deleteByScheduledTask(ScheduledTaskEntity $scheduledTask): void { $this->entityManager->createQueryBuilder() ->delete(ScheduledTaskSubscriberEntity::class, 'sts') ->where('sts.task = :task') ->setParameter('task', $scheduledTask) ->getQuery() ->execute(); // delete was done via DQL, make sure the entities are also detached from the entity manager $this->detachAll(function (ScheduledTaskSubscriberEntity $entity) use ($scheduledTask) { return $entity->getTask() === $scheduledTask; }); } public function deleteByScheduledTaskAndSubscriberIds(ScheduledTaskEntity $scheduledTask, array $subscriberIds): void { $this->entityManager->createQueryBuilder() ->delete(ScheduledTaskSubscriberEntity::class, 'sts') ->where('sts.task = :task') ->andWhere('sts.subscriber IN (:subscriberIds)') ->setParameter('task', $scheduledTask) ->setParameter('subscriberIds', $subscriberIds, Connection::PARAM_INT_ARRAY) ->getQuery() ->execute(); // delete was done via DQL, make sure the entities are also detached from the entity manager $this->detachAll(function (ScheduledTaskSubscriberEntity $entity) use ($scheduledTask, $subscriberIds) { return $entity->getTask() === $scheduledTask && in_array($entity->getSubscriberId(), $subscriberIds, true); }); $this->checkCompleted($scheduledTask); } public function setSubscribers(ScheduledTaskEntity $task, array $subscriberIds): void { $this->deleteByScheduledTask($task); foreach ($subscriberIds as $subscriberId) { $this->createOrUpdate([ 'task_id' => $task->getId(), 'subscriber_id' => $subscriberId, ]); } } public function saveError(ScheduledTaskEntity $scheduledTask, int $subscriberId, string $errorMessage): void { $scheduledTaskSubscriber = $this->findOneBy(['task' => $scheduledTask, 'subscriber' => $subscriberId]); if ($scheduledTaskSubscriber instanceof ScheduledTaskSubscriberEntity) { $scheduledTaskSubscriber->setFailed(ScheduledTaskSubscriberEntity::FAIL_STATUS_FAILED); $scheduledTaskSubscriber->setProcessed(ScheduledTaskSubscriberEntity::STATUS_PROCESSED); $scheduledTaskSubscriber->setError($errorMessage); $this->persist($scheduledTaskSubscriber); $this->flush(); $this->checkCompleted($scheduledTask); } } public function countProcessed(ScheduledTaskEntity $scheduledTaskEntity): int { return $this->countBy(['task' => $scheduledTaskEntity, 'processed' => ScheduledTaskSubscriberEntity::STATUS_PROCESSED]); } public function countUnprocessed(ScheduledTaskEntity $scheduledTaskEntity): int { return $this->countBy(['task' => $scheduledTaskEntity, 'processed' => ScheduledTaskSubscriberEntity::STATUS_UNPROCESSED]); } private function checkCompleted(ScheduledTaskEntity $task): void { $count = $this->countUnprocessed($task); if ($count === 0) { $task->setStatus(ScheduledTaskEntity::STATUS_COMPLETED); $task->setProcessedAt(Carbon::createFromTimestamp(WPFunctions::get()->currentTime('timestamp'))); $this->entityManager->flush(); } } private function getBaseSubscribersIdsBatchForTaskQuery(int $taskId, int $lastProcessedSubscriberId): QueryBuilder { return $this->entityManager ->createQueryBuilder() ->from(ScheduledTaskSubscriberEntity::class, 'sts') ->andWhere('sts.task = :taskId') ->andWhere('sts.subscriber > :lastProcessedSubscriberId') ->andWhere('sts.processed = :status') ->setParameter('taskId', $taskId) ->setParameter('lastProcessedSubscriberId', $lastProcessedSubscriberId) ->setParameter('status', ScheduledTaskSubscriberEntity::STATUS_UNPROCESSED); } }
Fatal error: Uncaught Error: Class "MailPoet\Newsletter\Sending\ScheduledTaskSubscribersRepository" not found in /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php:4121 Stack trace: #0 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(4141): MailPoetGenerated\FreeCachedContainer->getScheduledTaskSubscribersRepositoryService() #1 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(4031): MailPoetGenerated\FreeCachedContainer->getSendingQueuesRepositoryService() #2 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(5088): MailPoetGenerated\FreeCachedContainer->getRenderer6Service() #3 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(5098): MailPoetGenerated\FreeCachedContainer->getConfirmationEmailCustomizerService() #4 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(5198): MailPoetGenerated\FreeCachedContainer->getConfirmationEmailMailerService() #5 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(5368): MailPoetGenerated\FreeCachedContainer->getSubscriberActionsService() #6 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2612): MailPoetGenerated\FreeCachedContainer->getCommentService() #7 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2640): MailPoetGenerated\FreeCachedContainer->getHooks2Service() #8 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(122): MailPoetGenerated\FreeCachedContainer->getInitializerService() #9 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(110): MailPoetVendor\Symfony\Component\DependencyInjection\Container->make('MailPoet\\Config...', 1) #10 /htdocs/wp-content/plugins/mailpoet/lib/DI/ContainerWrapper.php(39): MailPoetVendor\Symfony\Component\DependencyInjection\Container->get('MailPoet\\Config...') #11 /htdocs/wp-content/plugins/mailpoet/mailpoet_initializer.php(89): MailPoet\DI\ContainerWrapper->get('MailPoet\\Config...') #12 /htdocs/wp-content/plugins/mailpoet/mailpoet.php(194): require_once('/htdocs/wp-cont...') #13 /htdocs/wp-settings.php(526): include_once('/htdocs/wp-cont...') #14 /htdocs/wp-config.php(85): require_once('/htdocs/wp-sett...') #15 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #16 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #17 /htdocs/index.php(17): require('/htdocs/wp-blog...') #18 {main} thrown in /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php on line 4121