diff --git a/classes/Task/AbstractTask.php b/classes/Task/AbstractTask.php index a97aefaa2..f3573d8d0 100644 --- a/classes/Task/AbstractTask.php +++ b/classes/Task/AbstractTask.php @@ -180,26 +180,8 @@ public function setErrorFlag(): void } } - /** - * @throws Exception - */ public function init(): void { - $this->container->initPrestaShopCore(); - $this->setupEnvironment(); - } - - /** - * @throws Exception - */ - protected function setupEnvironment(): void - { - $updateConfiguration = $this->container->getUpdateConfiguration(); - - if ($this::TASK_TYPE === TaskType::TASK_TYPE_UPDATE && $updateConfiguration->isChannelLocal()) { - $archiveXml = $updateConfiguration->getLocalChannelXml(); - $this->container->getFileLoader()->addXmlMd5File($this->container->getUpgrader()->getDestinationVersion(), $this->container->getProperty(UpgradeContainer::DOWNLOAD_PATH) . DIRECTORY_SEPARATOR . $archiveXml); - } } abstract public function run(): int; diff --git a/classes/Task/Backup/BackupDatabase.php b/classes/Task/Backup/BackupDatabase.php index 6c8e97b8b..b7d13adf6 100644 --- a/classes/Task/Backup/BackupDatabase.php +++ b/classes/Task/Backup/BackupDatabase.php @@ -39,6 +39,14 @@ class BackupDatabase extends AbstractTask const MAX_SIZE_PER_INSERT_STMT = 950000; + /** + * @throws Exception + */ + public function init(): void + { + $this->container->initPrestaShopCore(); + } + /** * @throws Exception */ diff --git a/classes/Task/Restore/RestoreFiles.php b/classes/Task/Restore/RestoreFiles.php index 18f85021f..ef3bd3c77 100644 --- a/classes/Task/Restore/RestoreFiles.php +++ b/classes/Task/Restore/RestoreFiles.php @@ -124,9 +124,4 @@ public function run(): int return ExitCode::SUCCESS; } - - public function init(): void - { - // Do nothing - } } diff --git a/classes/Task/Restore/RestoreInitialization.php b/classes/Task/Restore/RestoreInitialization.php index 60aed9a3e..1b4484e8e 100644 --- a/classes/Task/Restore/RestoreInitialization.php +++ b/classes/Task/Restore/RestoreInitialization.php @@ -110,9 +110,4 @@ public function run(): int return ExitCode::SUCCESS; } - - public function init(): void - { - // Do nothing - } } diff --git a/classes/Task/Update/CleanDatabase.php b/classes/Task/Update/CleanDatabase.php index f466131dd..277fec0dd 100644 --- a/classes/Task/Update/CleanDatabase.php +++ b/classes/Task/Update/CleanDatabase.php @@ -21,6 +21,7 @@ namespace PrestaShop\Module\AutoUpgrade\Task\Update; +use Exception; use PrestaShop\Module\AutoUpgrade\Task\AbstractTask; use PrestaShop\Module\AutoUpgrade\Task\ExitCode; use PrestaShop\Module\AutoUpgrade\Task\TaskName; @@ -53,4 +54,12 @@ public function run(): int return ExitCode::SUCCESS; } + + /** + * @throws Exception + */ + public function init(): void + { + $this->container->initPrestaShopCore(); + } } diff --git a/classes/Task/Update/Download.php b/classes/Task/Update/Download.php index f1c3e28af..2cad0eefb 100644 --- a/classes/Task/Update/Download.php +++ b/classes/Task/Update/Download.php @@ -37,6 +37,14 @@ class Download extends AbstractTask { const TASK_TYPE = TaskType::TASK_TYPE_UPDATE; + /** + * @throws Exception + */ + public function init(): void + { + $this->container->initPrestaShopCore(); + } + /** * @throws Exception */ diff --git a/classes/Task/Update/Unzip.php b/classes/Task/Update/Unzip.php index 70d9dda6e..b4e4760fb 100644 --- a/classes/Task/Update/Unzip.php +++ b/classes/Task/Update/Unzip.php @@ -36,6 +36,14 @@ class Unzip extends AbstractTask { const TASK_TYPE = TaskType::TASK_TYPE_UPDATE; + /** + * @throws Exception + */ + public function init(): void + { + $this->container->initPrestaShopCore(); + } + /** * @throws Exception */ diff --git a/classes/Task/Update/UpdateDatabase.php b/classes/Task/Update/UpdateDatabase.php index cd53461c2..dc89b95c3 100644 --- a/classes/Task/Update/UpdateDatabase.php +++ b/classes/Task/Update/UpdateDatabase.php @@ -117,7 +117,7 @@ public function init(): void // Migrating settings file $this->container->initPrestaShopAutoloader(); - parent::init(); + $this->container->initPrestaShopCore(); } /** diff --git a/classes/Task/Update/UpdateFiles.php b/classes/Task/Update/UpdateFiles.php index c68601a96..9e1c804b0 100644 --- a/classes/Task/Update/UpdateFiles.php +++ b/classes/Task/Update/UpdateFiles.php @@ -196,6 +196,12 @@ protected function warmUp(): int $this->container->getCompletionCalculator()->getBasePercentageOfTask(self::class) ); + $updateConfiguration = $this->container->getUpdateConfiguration(); + if ($updateConfiguration->isChannelLocal()) { + $archiveXml = $updateConfiguration->getLocalChannelXml(); + $this->container->getFileLoader()->addXmlMd5File($this->container->getUpgrader()->getDestinationVersion(), $this->container->getProperty(UpgradeContainer::DOWNLOAD_PATH) . DIRECTORY_SEPARATOR . $archiveXml); + } + // Get path to the folder with release we will use to upgrade and check if it's valid $newReleasePath = $this->container->getProperty(UpgradeContainer::LATEST_PATH); if (!$this->container->getFilesystemAdapter()->isReleaseValid($newReleasePath)) { @@ -274,9 +280,4 @@ protected function warmUp(): int return ExitCode::SUCCESS; } - - public function init(): void - { - $this->setupEnvironment(); - } } diff --git a/classes/Task/Update/UpdateModules.php b/classes/Task/Update/UpdateModules.php index 9be595551..d16264f7a 100644 --- a/classes/Task/Update/UpdateModules.php +++ b/classes/Task/Update/UpdateModules.php @@ -161,6 +161,14 @@ public function warmUp(): int return ExitCode::SUCCESS; } + /** + * @throws Exception + */ + public function init(): void + { + $this->container->initPrestaShopCore(); + } + private function handleException(UpgradeException $e): void { if ($e->getSeverity() === UpgradeException::SEVERITY_ERROR) {