| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
/** |
| 8 |
* Owns the set of database-upgrade components. |
| 9 |
* |
| 10 |
* Instantiates each upgrade component with the owning coordinator and the |
| 11 |
* shared dependency map, exposes every component through a typed accessor, and |
| 12 |
* re-pushes a refreshed dependency map to all of them when the coordinator's |
| 13 |
* collaborators change (e.g. after a test swaps in a mock DataAccess). |
| 14 |
* |
| 15 |
* This isolates the 17-component instantiation/refresh lifecycle from |
| 16 |
* {@see ABJ_404_Solution_DatabaseUpgradesEtc}, whose remaining job is to be the |
| 17 |
* public upgrade facade. The registry IS the coordinator passed to each |
| 18 |
* component, so components reach their siblings through it. Constructed by the |
| 19 |
* facade only. |
| 20 |
*/ |
| 21 |
class ABJ_404_Solution_DatabaseUpgradeComponentRegistry implements ABJ_404_Solution_DatabaseUpgradeCoordinator { |
| 22 |
|
| 23 |
/** @var ABJ_404_Solution_DatabaseUpgradeNGram */ |
| 24 |
private $nGramUpgrade; |
| 25 |
|
| 26 |
/** @var ABJ_404_Solution_DatabaseUpgradeEngineNormalization */ |
| 27 |
private $engineNormalizationUpgrade; |
| 28 |
|
| 29 |
/** @var ABJ_404_Solution_DatabaseUpgradeCollationDrift */ |
| 30 |
private $collationDriftUpgrade; |
| 31 |
|
| 32 |
/** @var ABJ_404_Solution_DatabaseUpgradeSelfHeal */ |
| 33 |
private $selfHealUpgrade; |
| 34 |
|
| 35 |
/** @var ABJ_404_Solution_DatabaseUpgradeCanonicalUrlBackfill */ |
| 36 |
private $canonicalUrlBackfillUpgrade; |
| 37 |
|
| 38 |
/** @var ABJ_404_Solution_DatabaseUpgradeRedirectsDenormBackfill */ |
| 39 |
private $redirectsDenormBackfillUpgrade; |
| 40 |
|
| 41 |
/** @var ABJ_404_Solution_DatabaseUpgradeRedirectsSortKeyBackfill */ |
| 42 |
private $redirectsSortKeyBackfillUpgrade; |
| 43 |
|
| 44 |
/** @var ABJ_404_Solution_DatabaseUpgradeRedirectsDenormReconcile */ |
| 45 |
private $redirectsDenormReconcileUpgrade; |
| 46 |
|
| 47 |
/** @var ABJ_404_Solution_DatabaseUpgradeDailyMaintenance */ |
| 48 |
private $dailyMaintenanceUpgrade; |
| 49 |
|
| 50 |
/** @var ABJ_404_Solution_DatabaseUpgradePluginUpdate */ |
| 51 |
private $pluginUpdateUpgrade; |
| 52 |
|
| 53 |
/** @var ABJ_404_Solution_DatabaseUpgradeTableRepair */ |
| 54 |
private $tableRepairUpgrade; |
| 55 |
|
| 56 |
/** @var ABJ_404_Solution_DatabaseUpgradeDropStagedViewTables */ |
| 57 |
private $dropStagedViewTablesUpgrade; |
| 58 |
|
| 59 |
/** @var ABJ_404_Solution_DatabaseUpgradeIndexes */ |
| 60 |
private $indexesUpgrade; |
| 61 |
|
| 62 |
/** @var ABJ_404_Solution_DatabaseUpgradeOrphanAdoption */ |
| 63 |
private $orphanAdoptionUpgrade; |
| 64 |
|
| 65 |
/** @var ABJ_404_Solution_DatabaseUpgradeMultiSite */ |
| 66 |
private $multiSiteUpgrade; |
| 67 |
|
| 68 |
/** @var ABJ_404_Solution_DatabaseUpgradeSchemaDiff */ |
| 69 |
private $schemaDiffUpgrade; |
| 70 |
|
| 71 |
/** @var ABJ_404_Solution_DatabaseUpgradeBootstrap */ |
| 72 |
private $bootstrapUpgrade; |
| 73 |
|
| 74 |
/** |
| 75 |
* @param array<string, mixed> $deps Shared component dependency map. |
| 76 |
*/ |
| 77 |
public function __construct(array $deps) { |
| 78 |
$this->nGramUpgrade = new ABJ_404_Solution_DatabaseUpgradeNGram($this, $deps); |
| 79 |
$this->engineNormalizationUpgrade = new ABJ_404_Solution_DatabaseUpgradeEngineNormalization($this, $deps); |
| 80 |
$this->collationDriftUpgrade = new ABJ_404_Solution_DatabaseUpgradeCollationDrift($this, $deps); |
| 81 |
$this->selfHealUpgrade = new ABJ_404_Solution_DatabaseUpgradeSelfHeal($this, $deps); |
| 82 |
$this->canonicalUrlBackfillUpgrade = new ABJ_404_Solution_DatabaseUpgradeCanonicalUrlBackfill($this, $deps); |
| 83 |
$this->redirectsDenormBackfillUpgrade = new ABJ_404_Solution_DatabaseUpgradeRedirectsDenormBackfill($this, $deps); |
| 84 |
$this->redirectsSortKeyBackfillUpgrade = new ABJ_404_Solution_DatabaseUpgradeRedirectsSortKeyBackfill($this, $deps); |
| 85 |
$this->redirectsDenormReconcileUpgrade = new ABJ_404_Solution_DatabaseUpgradeRedirectsDenormReconcile($this, $deps); |
| 86 |
$this->dailyMaintenanceUpgrade = new ABJ_404_Solution_DatabaseUpgradeDailyMaintenance($this, $deps); |
| 87 |
$this->pluginUpdateUpgrade = new ABJ_404_Solution_DatabaseUpgradePluginUpdate($this, $deps); |
| 88 |
$this->tableRepairUpgrade = new ABJ_404_Solution_DatabaseUpgradeTableRepair($this, $deps); |
| 89 |
$this->dropStagedViewTablesUpgrade = new ABJ_404_Solution_DatabaseUpgradeDropStagedViewTables($this, $deps); |
| 90 |
$this->indexesUpgrade = new ABJ_404_Solution_DatabaseUpgradeIndexes($this, $deps); |
| 91 |
$this->orphanAdoptionUpgrade = new ABJ_404_Solution_DatabaseUpgradeOrphanAdoption($this, $deps); |
| 92 |
$this->multiSiteUpgrade = new ABJ_404_Solution_DatabaseUpgradeMultiSite($this, $deps); |
| 93 |
$this->schemaDiffUpgrade = new ABJ_404_Solution_DatabaseUpgradeSchemaDiff($this, $deps); |
| 94 |
$this->bootstrapUpgrade = new ABJ_404_Solution_DatabaseUpgradeBootstrap($this, $deps); |
| 95 |
} |
| 96 |
|
| 97 |
/** |
| 98 |
* Re-push a refreshed dependency map to every component. |
| 99 |
* |
| 100 |
* @param array<string, mixed> $deps |
| 101 |
* @return void |
| 102 |
*/ |
| 103 |
public function refreshDependencies(array $deps): void { |
| 104 |
foreach ($this->all() as $component) { |
| 105 |
$component->replaceDatabaseUpgradeDependencies($deps); |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
/** @return ABJ_404_Solution_DatabaseUpgradeComponent[] */ |
| 110 |
private function all(): array { |
| 111 |
return [ |
| 112 |
$this->nGramUpgrade, |
| 113 |
$this->engineNormalizationUpgrade, |
| 114 |
$this->collationDriftUpgrade, |
| 115 |
$this->selfHealUpgrade, |
| 116 |
$this->canonicalUrlBackfillUpgrade, |
| 117 |
$this->redirectsDenormBackfillUpgrade, |
| 118 |
$this->redirectsSortKeyBackfillUpgrade, |
| 119 |
$this->redirectsDenormReconcileUpgrade, |
| 120 |
$this->dailyMaintenanceUpgrade, |
| 121 |
$this->pluginUpdateUpgrade, |
| 122 |
$this->tableRepairUpgrade, |
| 123 |
$this->dropStagedViewTablesUpgrade, |
| 124 |
$this->indexesUpgrade, |
| 125 |
$this->orphanAdoptionUpgrade, |
| 126 |
$this->multiSiteUpgrade, |
| 127 |
$this->schemaDiffUpgrade, |
| 128 |
$this->bootstrapUpgrade, |
| 129 |
]; |
| 130 |
} |
| 131 |
|
| 132 |
public function nGramUpgrade(): ABJ_404_Solution_DatabaseUpgradeNGram { return $this->nGramUpgrade; } |
| 133 |
|
| 134 |
public function engineNormalizationUpgrade(): ABJ_404_Solution_DatabaseUpgradeEngineNormalization { return $this->engineNormalizationUpgrade; } |
| 135 |
|
| 136 |
public function collationDriftUpgrade(): ABJ_404_Solution_DatabaseUpgradeCollationDrift { return $this->collationDriftUpgrade; } |
| 137 |
|
| 138 |
public function selfHealUpgrade(): ABJ_404_Solution_DatabaseUpgradeSelfHeal { return $this->selfHealUpgrade; } |
| 139 |
|
| 140 |
public function canonicalUrlBackfillUpgrade(): ABJ_404_Solution_DatabaseUpgradeCanonicalUrlBackfill { return $this->canonicalUrlBackfillUpgrade; } |
| 141 |
|
| 142 |
public function redirectsDenormBackfillUpgrade(): ABJ_404_Solution_DatabaseUpgradeRedirectsDenormBackfill { return $this->redirectsDenormBackfillUpgrade; } |
| 143 |
|
| 144 |
public function redirectsSortKeyBackfillUpgrade(): ABJ_404_Solution_DatabaseUpgradeRedirectsSortKeyBackfill { return $this->redirectsSortKeyBackfillUpgrade; } |
| 145 |
|
| 146 |
public function redirectsDenormReconcileUpgrade(): ABJ_404_Solution_DatabaseUpgradeRedirectsDenormReconcile { return $this->redirectsDenormReconcileUpgrade; } |
| 147 |
|
| 148 |
public function dailyMaintenanceUpgrade(): ABJ_404_Solution_DatabaseUpgradeDailyMaintenance { return $this->dailyMaintenanceUpgrade; } |
| 149 |
|
| 150 |
public function pluginUpdateUpgrade(): ABJ_404_Solution_DatabaseUpgradePluginUpdate { return $this->pluginUpdateUpgrade; } |
| 151 |
|
| 152 |
public function tableRepairUpgrade(): ABJ_404_Solution_DatabaseUpgradeTableRepair { return $this->tableRepairUpgrade; } |
| 153 |
|
| 154 |
public function dropStagedViewTablesUpgrade(): ABJ_404_Solution_DatabaseUpgradeDropStagedViewTables { return $this->dropStagedViewTablesUpgrade; } |
| 155 |
|
| 156 |
public function indexesUpgrade(): ABJ_404_Solution_DatabaseUpgradeIndexes { return $this->indexesUpgrade; } |
| 157 |
|
| 158 |
public function orphanAdoptionUpgrade(): ABJ_404_Solution_DatabaseUpgradeOrphanAdoption { return $this->orphanAdoptionUpgrade; } |
| 159 |
|
| 160 |
public function multiSiteUpgrade(): ABJ_404_Solution_DatabaseUpgradeMultiSite { return $this->multiSiteUpgrade; } |
| 161 |
|
| 162 |
public function schemaDiffUpgrade(): ABJ_404_Solution_DatabaseUpgradeSchemaDiff { return $this->schemaDiffUpgrade; } |
| 163 |
|
| 164 |
public function bootstrapUpgrade(): ABJ_404_Solution_DatabaseUpgradeBootstrap { return $this->bootstrapUpgrade; } |
| 165 |
} |
| 166 |
|