Migration_20221028_105818_App.php
3 years ago
Migration_20230109_144830.php
3 years ago
Migration_20230131_121621.php
3 years ago
Migration_20230419_080000.php
3 years ago
Migration_20230425_211517.php
3 years ago
Migration_20230712_180341.php
3 years ago
Migration_20230803_200413_App.php
2 years ago
Migration_20230825_093531_App.php
1 year ago
Migration_20231128_120355_App.php
1 year ago
Migration_20240202_130053_App.php
2 years ago
Migration_20240207_105912_App.php
1 year ago
Migration_20240322_110443_App.php
1 year ago
Migration_20240730_212419_App.php
2 years ago
Migration_20241015_105511_App.php
1 year ago
Migration_20241128_114257_App.php
1 year ago
Migration_20250120_094614_App.php
1 year ago
Migration_20250501_114655_App.php
11 months ago
Migration_20260421_155908_App.php
3 months ago
Migration_20260515_120000_App.php
3 months ago
Migration_20260623_120000_App.php
1 month ago
Migration_20260805_120000_App.php
1 week ago
index.php
3 years ago
Migration_20230419_080000.php
42 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Migrations\App; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Entities\NewsletterEntity; |
| 9 | use MailPoet\Migrator\AppMigration; |
| 10 | use MailPoet\Newsletter\NewslettersRepository; |
| 11 | use MailPoet\Newsletter\Scheduler\PostNotificationScheduler; |
| 12 | |
| 13 | class Migration_20230419_080000 extends AppMigration { |
| 14 | /** @var NewslettersRepository */ |
| 15 | private $newslettersRepository; |
| 16 | |
| 17 | /** @var PostNotificationScheduler */ |
| 18 | private $postNotificationScheduler; |
| 19 | |
| 20 | public function run(): void { |
| 21 | $this->newslettersRepository = $this->container->get(NewslettersRepository::class); |
| 22 | $this->postNotificationScheduler = $this->container->get(PostNotificationScheduler::class); |
| 23 | $this->fixPostNotificationScheduleTime(); |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * Because we released PostNotificationScheduler that didn't schedule notifications with the minute resolution, |
| 28 | * which was added in version 4.10.0, we need to fix the scheduled time for all notifications. |
| 29 | * |
| 30 | * Ticket with bug: https://mailpoet.atlassian.net/browse/MAILPOET-5244 |
| 31 | * Ticket with adding minute resolution: https://mailpoet.atlassian.net/browse/MAILPOET-4602 |
| 32 | * |
| 33 | * @return void |
| 34 | */ |
| 35 | private function fixPostNotificationScheduleTime() { |
| 36 | $newsletters = $this->newslettersRepository->findBy(['type' => NewsletterEntity::TYPE_NOTIFICATION]); |
| 37 | foreach ($newsletters as $newsletter) { |
| 38 | $this->postNotificationScheduler->processPostNotificationSchedule($newsletter); |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 |