From 6f24819216d8c16f4f970e895e0c276f215a6d3b Mon Sep 17 00:00:00 2001 From: Radomir Butacevic Date: Thu, 7 Nov 2024 14:38:35 +0100 Subject: [PATCH 1/2] Add fix for scheduled tasks --- .../DailyProductSyncScheduledTaskHandler.php | 10 ++-------- .../EntityChangelogScheduledTaskHandler.php | 10 ++-------- .../OldJobCleanupScheduledTaskHandler.php | 10 ++-------- .../OldNostoDataCleanupScheduledTaskHandler.php | 10 ++-------- 4 files changed, 8 insertions(+), 32 deletions(-) diff --git a/src/Service/ScheduledTask/DailyProductSyncScheduledTaskHandler.php b/src/Service/ScheduledTask/DailyProductSyncScheduledTaskHandler.php index b514d82d..8aa1ebc9 100644 --- a/src/Service/ScheduledTask/DailyProductSyncScheduledTaskHandler.php +++ b/src/Service/ScheduledTask/DailyProductSyncScheduledTaskHandler.php @@ -20,7 +20,9 @@ use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler; use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Messenger\Attribute\AsMessageHandler; +#[AsMessageHandler(handles: DailyProductSyncScheduledTask::class)] class DailyProductSyncScheduledTaskHandler extends ScheduledTaskHandler { private const LAST_EXECUTION_TIME_CONFIG = 'dailySyncLastTime'; @@ -36,14 +38,6 @@ public function __construct( parent::__construct($scheduledTaskRepository); } - /** - * @return ScheduledTask[] - */ - public static function getHandledMessages(): iterable - { - return [DailyProductSyncScheduledTask::class]; - } - public function run(): void { if ($this->isTimeToRunJob()) { diff --git a/src/Service/ScheduledTask/EntityChangelogScheduledTaskHandler.php b/src/Service/ScheduledTask/EntityChangelogScheduledTaskHandler.php index f98a6ea5..f58075de 100644 --- a/src/Service/ScheduledTask/EntityChangelogScheduledTaskHandler.php +++ b/src/Service/ScheduledTask/EntityChangelogScheduledTaskHandler.php @@ -11,7 +11,9 @@ use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTask; use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler; use Shopware\Core\Framework\Uuid\Uuid; +use Symfony\Component\Messenger\Attribute\AsMessageHandler; +#[AsMessageHandler(handles: EntityChangelogScheduledTask::class)] class EntityChangelogScheduledTaskHandler extends ScheduledTaskHandler implements GeneratingHandlerInterface { public function __construct( @@ -21,14 +23,6 @@ public function __construct( parent::__construct($scheduledTaskRepository); } - /** - * @return ScheduledTask[] - */ - public static function getHandledMessages(): iterable - { - return [EntityChangelogScheduledTask::class]; - } - public function run(): void { $jobMessage = new EntityChangelogSyncMessage(Uuid::randomHex()); diff --git a/src/Service/ScheduledTask/OldJobCleanupScheduledTaskHandler.php b/src/Service/ScheduledTask/OldJobCleanupScheduledTaskHandler.php index 4cbceb0c..9fa9d5c3 100644 --- a/src/Service/ScheduledTask/OldJobCleanupScheduledTaskHandler.php +++ b/src/Service/ScheduledTask/OldJobCleanupScheduledTaskHandler.php @@ -19,7 +19,9 @@ use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTask; use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler; use Throwable; +use Symfony\Component\Messenger\Attribute\AsMessageHandler; +#[AsMessageHandler(handles: OldJobCleanupScheduledTask::class)] class OldJobCleanupScheduledTaskHandler extends ScheduledTaskHandler { public function __construct( @@ -31,14 +33,6 @@ public function __construct( parent::__construct($scheduledTaskRepository); } - /** - * @return ScheduledTask[] - */ - public static function getHandledMessages(): iterable - { - return [OldJobCleanupScheduledTask::class]; - } - public function run(): void { try { diff --git a/src/Service/ScheduledTask/OldNostoDataCleanupScheduledTaskHandler.php b/src/Service/ScheduledTask/OldNostoDataCleanupScheduledTaskHandler.php index c748351a..94c0f05e 100644 --- a/src/Service/ScheduledTask/OldNostoDataCleanupScheduledTaskHandler.php +++ b/src/Service/ScheduledTask/OldNostoDataCleanupScheduledTaskHandler.php @@ -13,7 +13,9 @@ use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTask; use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler; use Throwable; +use Symfony\Component\Messenger\Attribute\AsMessageHandler; +#[AsMessageHandler(handles: OldNostoDataCleanupScheduledTask::class)] class OldNostoDataCleanupScheduledTaskHandler extends ScheduledTaskHandler { public function __construct( @@ -25,14 +27,6 @@ public function __construct( parent::__construct($scheduledTaskRepository); } - /** - * @return ScheduledTask[] - */ - public static function getHandledMessages(): iterable - { - return [OldNostoDataCleanupScheduledTask::class]; - } - public function run(): void { try { From e97bcd0c7d8669d338429bb652f0a66141db880b Mon Sep 17 00:00:00 2001 From: Radomir Butacevic Date: Thu, 7 Nov 2024 14:43:55 +0100 Subject: [PATCH 2/2] Adapt PHPLint tests --- .../ScheduledTask/DailyProductSyncScheduledTaskHandler.php | 1 - .../ScheduledTask/EntityChangelogScheduledTaskHandler.php | 1 - .../ScheduledTask/OldJobCleanupScheduledTaskHandler.php | 3 +-- .../ScheduledTask/OldNostoDataCleanupScheduledTaskHandler.php | 3 +-- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Service/ScheduledTask/DailyProductSyncScheduledTaskHandler.php b/src/Service/ScheduledTask/DailyProductSyncScheduledTaskHandler.php index 8aa1ebc9..591a0979 100644 --- a/src/Service/ScheduledTask/DailyProductSyncScheduledTaskHandler.php +++ b/src/Service/ScheduledTask/DailyProductSyncScheduledTaskHandler.php @@ -16,7 +16,6 @@ use Shopware\Core\Framework\Api\Context\SystemSource; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; -use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTask; use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler; use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface; use Symfony\Component\HttpFoundation\Request; diff --git a/src/Service/ScheduledTask/EntityChangelogScheduledTaskHandler.php b/src/Service/ScheduledTask/EntityChangelogScheduledTaskHandler.php index f58075de..b7f0a898 100644 --- a/src/Service/ScheduledTask/EntityChangelogScheduledTaskHandler.php +++ b/src/Service/ScheduledTask/EntityChangelogScheduledTaskHandler.php @@ -8,7 +8,6 @@ use Nosto\Scheduler\Model\Job\GeneratingHandlerInterface; use Nosto\Scheduler\Model\JobScheduler; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; -use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTask; use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler; use Shopware\Core\Framework\Uuid\Uuid; use Symfony\Component\Messenger\Attribute\AsMessageHandler; diff --git a/src/Service/ScheduledTask/OldJobCleanupScheduledTaskHandler.php b/src/Service/ScheduledTask/OldJobCleanupScheduledTaskHandler.php index 9fa9d5c3..df1d66ff 100644 --- a/src/Service/ScheduledTask/OldJobCleanupScheduledTaskHandler.php +++ b/src/Service/ScheduledTask/OldJobCleanupScheduledTaskHandler.php @@ -16,10 +16,9 @@ use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\ContainsFilter; use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter; use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\RangeFilter; -use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTask; use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler; -use Throwable; use Symfony\Component\Messenger\Attribute\AsMessageHandler; +use Throwable; #[AsMessageHandler(handles: OldJobCleanupScheduledTask::class)] class OldJobCleanupScheduledTaskHandler extends ScheduledTaskHandler diff --git a/src/Service/ScheduledTask/OldNostoDataCleanupScheduledTaskHandler.php b/src/Service/ScheduledTask/OldNostoDataCleanupScheduledTaskHandler.php index 94c0f05e..7f022203 100644 --- a/src/Service/ScheduledTask/OldNostoDataCleanupScheduledTaskHandler.php +++ b/src/Service/ScheduledTask/OldNostoDataCleanupScheduledTaskHandler.php @@ -10,10 +10,9 @@ use Psr\Log\LoggerInterface; use Shopware\Core\Defaults; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; -use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTask; use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler; -use Throwable; use Symfony\Component\Messenger\Attribute\AsMessageHandler; +use Throwable; #[AsMessageHandler(handles: OldNostoDataCleanupScheduledTask::class)] class OldNostoDataCleanupScheduledTaskHandler extends ScheduledTaskHandler