| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Yatra\Upgrades\Versions; |
| 6 |
|
| 7 |
use Yatra\Services\ReviewReminderService; |
| 8 |
use Yatra\Upgrades\AbstractUpgradeStep; |
| 9 |
|
| 10 |
/** |
| 11 |
* Free 3.0.17: drain review reminders queued against the old anchor. |
| 12 |
* |
| 13 |
* Until this release the review request was scheduled for "now + N days", |
| 14 |
* measured from the moment a booking was marked completed. The daily |
| 15 |
* auto-completion sweep can complete a long backlog of finished tours in a |
| 16 |
* single run, so sites ended up with a queue of reminders for trips that had |
| 17 |
* ended weeks or months earlier — all due to fire together. |
| 18 |
* |
| 19 |
* {@see ReviewReminderService} now anchors on the tour's end date and refuses |
| 20 |
* anything older than its staleness cap, but those are decisions taken when the |
| 21 |
* reminder is scheduled. Events already sitting in wp_cron carry no such rule, |
| 22 |
* so upgrading alone would not spare the installs that are carrying one. This |
| 23 |
* clears them once. |
| 24 |
* |
| 25 |
* The service also re-checks the window when an event actually fires, so a |
| 26 |
* reminder queued between this step running and the upgrade completing is still |
| 27 |
* declined rather than sent. |
| 28 |
*/ |
| 29 |
final class Upgrade_3_0_17 extends AbstractUpgradeStep |
| 30 |
{ |
| 31 |
public static function targetVersion(): string |
| 32 |
{ |
| 33 |
return '3.0.17'; |
| 34 |
} |
| 35 |
|
| 36 |
public static function runOnHooks(): array |
| 37 |
{ |
| 38 |
return ['admin_init']; |
| 39 |
} |
| 40 |
|
| 41 |
public static function run(string $fromVersion, string $toVersion): void |
| 42 |
{ |
| 43 |
unset($fromVersion, $toVersion); |
| 44 |
|
| 45 |
ReviewReminderService::purgeStaleScheduledReminders(); |
| 46 |
} |
| 47 |
} |
| 48 |
|