diff --git a/application/Espo/Core/Job/Job.php b/application/Espo/Core/Job/Job.php new file mode 100644 index 0000000000..151415586a --- /dev/null +++ b/application/Espo/Core/Job/Job.php @@ -0,0 +1,41 @@ +format('Y-m-d') . ' ' . $hour . ':' . $minute . ':00'; $timeZone = $this->config->get('timeZone'); + if (empty($timeZone)) { $timeZone = 'UTC'; } @@ -88,6 +90,7 @@ class CheckNewVersion implements Job /** * For backward compatibility. + * @deprecated */ protected function getEntityManager() { diff --git a/application/Espo/Jobs/Cleanup.php b/application/Espo/Jobs/Cleanup.php index 876309c27e..f1d4e59775 100644 --- a/application/Espo/Jobs/Cleanup.php +++ b/application/Espo/Jobs/Cleanup.php @@ -32,7 +32,7 @@ namespace Espo\Jobs; use Espo\Core\{ Utils\Config, ORM\EntityManager, - Jobs\Job, + Job\Job, Utils\Metadata, Utils\File\Manager as FileManager, InjectableFactory, diff --git a/application/Espo/Jobs/Dummy.php b/application/Espo/Jobs/Dummy.php index 3fcac98762..bf777cd3f7 100644 --- a/application/Espo/Jobs/Dummy.php +++ b/application/Espo/Jobs/Dummy.php @@ -30,7 +30,7 @@ namespace Espo\Jobs; use Espo\Core\{ - Jobs\Job, + Job\Job, }; class Dummy implements Job diff --git a/application/Espo/Jobs/ProcessJobQueueE0.php b/application/Espo/Jobs/ProcessJobQueueE0.php index 2f1c98e1c1..b271f4742f 100644 --- a/application/Espo/Jobs/ProcessJobQueueE0.php +++ b/application/Espo/Jobs/ProcessJobQueueE0.php @@ -32,7 +32,7 @@ namespace Espo\Jobs; use Espo\Core\{ Job\JobManager, Utils\Config, - Jobs\Job, + Job\Job, }; class ProcessJobQueueE0 implements Job diff --git a/application/Espo/Jobs/ProcessJobQueueQ0.php b/application/Espo/Jobs/ProcessJobQueueQ0.php index ee487e8aa5..0a07205298 100644 --- a/application/Espo/Jobs/ProcessJobQueueQ0.php +++ b/application/Espo/Jobs/ProcessJobQueueQ0.php @@ -32,7 +32,7 @@ namespace Espo\Jobs; use Espo\Core\{ Job\JobManager, Utils\Config, - Jobs\Job, + Job\Job, }; class ProcessJobQueueQ0 implements Job diff --git a/application/Espo/Jobs/ProcessJobQueueQ1.php b/application/Espo/Jobs/ProcessJobQueueQ1.php index bfa80dcfca..34c14ce83d 100644 --- a/application/Espo/Jobs/ProcessJobQueueQ1.php +++ b/application/Espo/Jobs/ProcessJobQueueQ1.php @@ -32,7 +32,7 @@ namespace Espo\Jobs; use Espo\Core\{ Job\JobManager, Utils\Config, - Jobs\Job, + Job\Job, }; class ProcessJobQueueQ1 implements Job diff --git a/application/Espo/Jobs/ProcessWebhookQueue.php b/application/Espo/Jobs/ProcessWebhookQueue.php index 5f06ecf2b3..f7d05f15ef 100644 --- a/application/Espo/Jobs/ProcessWebhookQueue.php +++ b/application/Espo/Jobs/ProcessWebhookQueue.php @@ -30,7 +30,7 @@ namespace Espo\Jobs; use Espo\Core\{ - Jobs\Job, + Job\Job, AclManager, Utils\Config, ORM\EntityManager, diff --git a/application/Espo/Jobs/SendEmailNotifications.php b/application/Espo/Jobs/SendEmailNotifications.php index 3d0a2c96e1..302c38d706 100644 --- a/application/Espo/Jobs/SendEmailNotifications.php +++ b/application/Espo/Jobs/SendEmailNotifications.php @@ -29,7 +29,7 @@ namespace Espo\Jobs; -use Espo\Core\Jobs\Job; +use Espo\Core\Job\Job; use Espo\Tools\EmailNotification\Processor; diff --git a/application/Espo/Modules/Crm/Jobs/ControlKnowledgeBaseArticleStatus.php b/application/Espo/Modules/Crm/Jobs/ControlKnowledgeBaseArticleStatus.php index 9b5985eb43..2078121f2b 100644 --- a/application/Espo/Modules/Crm/Jobs/ControlKnowledgeBaseArticleStatus.php +++ b/application/Espo/Modules/Crm/Jobs/ControlKnowledgeBaseArticleStatus.php @@ -24,7 +24,7 @@ namespace Espo\Modules\Crm\Jobs; use Espo\Core\{ ORM\EntityManager, - Jobs\Job, + Job\Job, }; class ControlKnowledgeBaseArticleStatus implements Job diff --git a/application/Espo/Modules/Crm/Jobs/ProcessMassEmail.php b/application/Espo/Modules/Crm/Jobs/ProcessMassEmail.php index fc54b6d744..e46a387f22 100644 --- a/application/Espo/Modules/Crm/Jobs/ProcessMassEmail.php +++ b/application/Espo/Modules/Crm/Jobs/ProcessMassEmail.php @@ -31,7 +31,7 @@ namespace Espo\Modules\Crm\Jobs; use Espo\Core\{ ORM\EntityManager, - Jobs\Job, + Job\Job, }; use Espo\{ @@ -43,11 +43,11 @@ use Throwable; class ProcessMassEmail implements Job { - protected $processor; + private $processor; - protected $queue; + private $queue; - protected $entityManager; + private $entityManager; public function __construct(Processor $processor, Queue $queue, EntityManager $entityManager) { @@ -58,7 +58,7 @@ class ProcessMassEmail implements Job public function run() : void { - $massEmailList = $this->entityManager + $pendingMassEmailList = $this->entityManager ->getRepository('MassEmail') ->where([ 'status' => 'Pending', @@ -66,7 +66,7 @@ class ProcessMassEmail implements Job ]) ->find(); - foreach ($massEmailList as $massEmail) { + foreach ($pendingMassEmailList as $massEmail) { try { $this->queue->create($massEmail); } diff --git a/application/Espo/Modules/Crm/Jobs/SendEmailReminders.php b/application/Espo/Modules/Crm/Jobs/SendEmailReminders.php index aebdb5efc8..efa818ce7a 100644 --- a/application/Espo/Modules/Crm/Jobs/SendEmailReminders.php +++ b/application/Espo/Modules/Crm/Jobs/SendEmailReminders.php @@ -32,7 +32,7 @@ namespace Espo\Modules\Crm\Jobs; use Espo\Core\{ InjectableFactory, ORM\EntityManager, - Jobs\Job, + Job\Job, }; use Espo\Modules\Crm\Business\Reminder\EmailReminder; @@ -43,10 +43,11 @@ use DateInterval; class SendEmailReminders implements Job { - const MAX_PORTION_SIZE = 10; + private const MAX_PORTION_SIZE = 10; - protected $injectableFactory; - protected $entityManager; + private $injectableFactory; + + private $entityManager; public function __construct(InjectableFactory $injectableFactory, EntityManager $entityManager) { @@ -77,8 +78,6 @@ class SendEmailReminders implements Job $emailReminder = $this->injectableFactory->create(EmailReminder::class); - $pdo = $this->entityManager->getPDO(); - foreach ($collection as $i => $entity) { if ($i >= self::MAX_PORTION_SIZE) { break; @@ -92,6 +91,7 @@ class SendEmailReminders implements Job 'Job SendEmailReminders '.$entity->id.': [' . $e->getCode() . '] ' .$e->getMessage() ); } + $this->entityManager ->getRepository('Reminder') ->deleteFromDb($entity->id); diff --git a/application/Espo/Modules/Crm/Jobs/SubmitPopupReminders.php b/application/Espo/Modules/Crm/Jobs/SubmitPopupReminders.php index 73a82bfaf1..a25177f0c2 100644 --- a/application/Espo/Modules/Crm/Jobs/SubmitPopupReminders.php +++ b/application/Espo/Modules/Crm/Jobs/SubmitPopupReminders.php @@ -33,7 +33,7 @@ use Espo\Core\{ ORM\EntityManager, Utils\Config, WebSocket\Submission as WebSocketSubmission, - Jobs\Job, + Job\Job, }; use Throwable; @@ -41,11 +41,13 @@ use DateTime; class SubmitPopupReminders implements Job { - const REMINDER_PAST_HOURS = 24; + private const REMINDER_PAST_HOURS = 24; - protected $entityManager; - protected $config; - protected $webSocketSubmission; + private $entityManager; + + private $config; + + private $webSocketSubmission; public function __construct(EntityManager $entityManager, Config $config, WebSocketSubmission $webSocketSubmission) {