Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not initialize in tasks the Core by default, only when requested #1160

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions classes/Task/AbstractTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions classes/Task/Backup/BackupDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
5 changes: 0 additions & 5 deletions classes/Task/Restore/RestoreFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,4 @@ public function run(): int

return ExitCode::SUCCESS;
}

public function init(): void
{
// Do nothing
}
}
5 changes: 0 additions & 5 deletions classes/Task/Restore/RestoreInitialization.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,4 @@ public function run(): int

return ExitCode::SUCCESS;
}

public function init(): void
{
// Do nothing
}
}
9 changes: 9 additions & 0 deletions classes/Task/Update/CleanDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -53,4 +54,12 @@ public function run(): int

return ExitCode::SUCCESS;
}

/**
* @throws Exception
*/
public function init(): void
{
$this->container->initPrestaShopCore();
}
}
8 changes: 8 additions & 0 deletions classes/Task/Update/Download.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
8 changes: 8 additions & 0 deletions classes/Task/Update/Unzip.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion classes/Task/Update/UpdateDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function init(): void

// Migrating settings file
$this->container->initPrestaShopAutoloader();
parent::init();
$this->container->initPrestaShopCore();
}

/**
Expand Down
11 changes: 6 additions & 5 deletions classes/Task/Update/UpdateFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -274,9 +280,4 @@ protected function warmUp(): int

return ExitCode::SUCCESS;
}

public function init(): void
{
$this->setupEnvironment();
}
}
8 changes: 8 additions & 0 deletions classes/Task/Update/UpdateModules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading