= $this->scheduledTasksRepository->findOneScheduledByNewsletterAndSubscriber($newsletter, $subscriber); if ($task) { $this->rescheduleAutomaticEmailSendingTask($newsletter, $task); } } } public function cancelAutomaticEmail(string $group, string $event, SubscriberEntity $subscriber): void { $newsletters = $this->scheduler->getNewsletters(NewsletterEntity::TYPE_AUTOMATIC, $group); if (empty($newsletters)) { return; } foreach ($newsletters as $newsletter) { if ($newsletter->getOptionValue(NewsletterOptionFieldEntity::NAME_EVENT) !== $event) { continue; } // try to find existing scheduled task for given subscriber $task = $this->scheduledTasksRepository->findOneScheduledByNewsletterAndSubscriber($newsletter, $subscriber); if ($task) { $queue = $task->getSendingQueue(); if ($queue instanceof SendingQueueEntity) { $this->sendingQueuesRepository->remove($queue); } $this->scheduledTaskSubscribersRepository->deleteByScheduledTask($task); $this->scheduledTasksRepository->remove($task); $this->scheduledTasksRepository->flush(); } } } public function createAutomaticEmailScheduledTask(NewsletterEntity $newsletter, ?SubscriberEntity $subscriber, ?array $meta = null): ScheduledTaskEntity { $scheduledTask = new ScheduledTaskEntity(); $scheduledTask->setType(SendingQueue::TASK_TYPE); $scheduledTask->setStatus(SendingQueueEntity::STATUS_SCHEDULED); $scheduledTask->setPriority(ScheduledTaskEntity::PRIORITY_MEDIUM); $scheduledTask->setScheduledAt($this->scheduler->getScheduledTimeWithDelay( $newsletter->getOptionValue(NewsletterOptionFieldEntity::NAME_AFTER_TIME_TYPE), $newsletter->getOptionValue(NewsletterOptionFieldEntity::NAME_AFTER_TIME_NUMBER) )); $this->scheduledTasksRepository->persist($scheduledTask); $this->scheduledTasksRepository->flush(); $sendingQueue = new SendingQueueEntity(); $sendingQueue->setNewsletter($newsletter); $sendingQueue->setTask($scheduledTask); // Because we changed the way how to updateCounts after sending we need to set initial counts $sendingQueue->setCountTotal($subscriber ? 1 : 0); $sendingQueue->setCountToProcess($subscriber ? 1 : 0); $scheduledTask->setSendingQueue($sendingQueue); if ($meta) { $scheduledTask->setMeta($meta); $sendingQueue->setMeta($meta); } $this->sendingQueuesRepository->persist($sendingQueue); $this->sendingQueuesRepository->flush(); if ($newsletter->getOptionValue(NewsletterOptionFieldEntity::NAME_SEND_TO) === 'user' && $subscriber) { $scheduledTaskSubscriber = new ScheduledTaskSubscriberEntity($scheduledTask, $subscriber); $this->scheduledTaskSubscribersRepository->persist($scheduledTaskSubscriber); $this->scheduledTaskSubscribersRepository->flush(); $scheduledTask->getSubscribers()->add($scheduledTaskSubscriber); } return $scheduledTask; } private function rescheduleAutomaticEmailSendingTask(NewsletterEntity $newsletter, ScheduledTaskEntity $scheduledTask, ?array $meta = null): void { $sendingQueue = $this->sendingQueuesRepository->findOneBy(['task' => $scheduledTask]); if (!$sendingQueue) { return; } if ($meta) { $sendingQueue->setMeta($meta); $scheduledTask->setMeta($meta); } // compute new 'scheduled_at' from now $scheduledTask->setScheduledAt($this->scheduler->getScheduledTimeWithDelay( $newsletter->getOptionValue(NewsletterOptionFieldEntity::NAME_AFTER_TIME_TYPE), $newsletter->getOptionValue(NewsletterOptionFieldEntity::NAME_AFTER_TIME_NUMBER) )); $this->sendingQueuesRepository->flush(); } }
Fatal error: Uncaught Error: Class "MailPoet\Newsletter\Scheduler\AutomaticEmailScheduler" not found in /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php:4041 Stack trace: #0 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(1371): MailPoetGenerated\FreeCachedContainer->getAutomaticEmailSchedulerService() #1 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(122): MailPoetGenerated\FreeCachedContainer->getAbandonedCartService() #2 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(110): MailPoetVendor\Symfony\Component\DependencyInjection\Container->make('MailPoet\\Automa...', 1) #3 /htdocs/wp-content/plugins/mailpoet/lib/DI/ContainerWrapper.php(39): MailPoetVendor\Symfony\Component\DependencyInjection\Container->get('MailPoet\\Automa...') #4 /htdocs/wp-content/plugins/mailpoet/lib/AutomaticEmails/WooCommerce/WooCommerceEventFactory.php(37): MailPoet\DI\ContainerWrapper->get('MailPoet\\Automa...') #5 /htdocs/wp-content/plugins/mailpoet/lib/AutomaticEmails/WooCommerce/WooCommerce.php(82): MailPoet\AutomaticEmails\WooCommerce\WooCommerceEventFactory->createEvent('AbandonedCart') #6 /htdocs/wp-includes/class-wp-hook.php(324): MailPoet\AutomaticEmails\WooCommerce\WooCommerce->setupEvents(Array) #7 /htdocs/wp-includes/plugin.php(205): WP_Hook->apply_filters(Array, Array) #8 [internal function]: apply_filters('mailpoet_woocom...', Array) #9 /htdocs/wp-content/plugins/mailpoet/lib/WP/Functions.php(65): call_user_func_array('apply_filters', Array) #10 /htdocs/wp-content/plugins/mailpoet/lib/AutomaticEmails/WooCommerce/WooCommerce.php(70): MailPoet\WP\Functions->applyFilters('mailpoet_woocom...', Array) #11 /htdocs/wp-includes/class-wp-hook.php(324): MailPoet\AutomaticEmails\WooCommerce\WooCommerce->setupGroup(Array) #12 /htdocs/wp-includes/plugin.php(205): WP_Hook->apply_filters(Array, Array) #13 [internal function]: apply_filters('mailpoet_automa...', Array) #14 /htdocs/wp-content/plugins/mailpoet/lib/WP/Functions.php(65): call_user_func_array('apply_filters', Array) #15 /htdocs/wp-content/plugins/mailpoet/lib/AutomaticEmails/AutomaticEmails.php(49): MailPoet\WP\Functions->applyFilters('mailpoet_automa...', Array) #16 /htdocs/wp-content/plugins/mailpoet/lib/Config/Initializer.php(560): MailPoet\AutomaticEmails\AutomaticEmails->getAutomaticEmails() #17 /htdocs/wp-content/plugins/mailpoet/lib/Config/Initializer.php(380): MailPoet\Config\Initializer->setupAutomaticEmails() #18 /htdocs/wp-includes/class-wp-hook.php(324): MailPoet\Config\Initializer->initialize('') #19 /htdocs/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #20 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #21 /htdocs/wp-settings.php(704): do_action('init') #22 /htdocs/wp-config.php(85): require_once('/htdocs/wp-sett...') #23 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #24 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #25 /htdocs/index.php(17): require('/htdocs/wp-blog...') #26 {main} thrown in /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php on line 4041