RoutineManagerService.php
51 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SmashBalloon\Reviews\Common\Services\Upgrade; |
| 4 | |
| 5 | use SmashBalloon\Reviews\Common\Services\Upgrade\Routines\AddUniqueReviewIndexRoutine; |
| 6 | use SmashBalloon\Reviews\Common\Services\Upgrade\Routines\BackfillWebsiteUrlRoutine; |
| 7 | use SmashBalloon\Reviews\Common\Services\Upgrade\Routines\LanguageCacheUpgradeRoutine; |
| 8 | use SmashBalloon\Reviews\Common\Services\Upgrade\Routines\RegisterWebsiteRoutine; |
| 9 | use Smashballoon\Stubs\Services\ServiceProvider; |
| 10 | use SmashBalloon\Reviews\Common\Container; |
| 11 | use SmashBalloon\Reviews\Common\Services\Upgrade\Routines\UpgradeRoutine; |
| 12 | use SmashBalloon\Reviews\Common\Services\Upgrade\Routines\V1Routine; |
| 13 | use SmashBalloon\Reviews\Common\Services\Upgrade\Routines\ClearReviewsDuplicateRoutine; |
| 14 | use SmashBalloon\Reviews\Common\Services\Upgrade\Routines\NewUserRatingRoutine; |
| 15 | use SmashBalloon\Reviews\Common\Services\Upgrade\Routines\ReconcileMigratedLicenseRoutine; |
| 16 | |
| 17 | class RoutineManagerService extends ServiceProvider{ |
| 18 | /** |
| 19 | * a list of upgrade routines to be executed, |
| 20 | * keep the correct order, newer is always at the end of the list. |
| 21 | * @var UpgradeRoutine[] |
| 22 | */ |
| 23 | private $routines = [ |
| 24 | V1Routine::class, |
| 25 | RegisterWebsiteRoutine::class, |
| 26 | LanguageCacheUpgradeRoutine::class, |
| 27 | ClearReviewsDuplicateRoutine::class, |
| 28 | NewUserRatingRoutine::class, |
| 29 | AddUniqueReviewIndexRoutine::class, |
| 30 | // SMASH-1281 — backfill website_url for installs that registered before |
| 31 | // this URL was tracked, so proactive migration detection works for the |
| 32 | // entire install base, not just future registrations. |
| 33 | BackfillWebsiteUrlRoutine::class, |
| 34 | // SMASH-1585 — one-shot recovery for sites silently wedged by a |
| 35 | // pre-2.6.3 migration fork (local license_status 'valid' but the relay |
| 36 | // has no active license for the new URL). Runs after the backfill so |
| 37 | // website_url is settled first. One ping, flips to Activate on a |
| 38 | // confirmed mismatch; never auto-reactivates. |
| 39 | ReconcileMigratedLicenseRoutine::class, |
| 40 | ]; |
| 41 | |
| 42 | public function register() |
| 43 | { |
| 44 | $container = Container::get_instance(); |
| 45 | |
| 46 | foreach ($this->routines as $routine) { |
| 47 | $container->get($routine)->register(); |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 |