From 4ea9446649c22153e56db63414a6e51f6a058df8 Mon Sep 17 00:00:00 2001 From: Thomas Nabord Date: Thu, 28 Jun 2018 15:23:15 +0100 Subject: [PATCH 1/2] Disable cache --- classes/UpgradeContainer.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/classes/UpgradeContainer.php b/classes/UpgradeContainer.php index 5dba67474..28363b715 100644 --- a/classes/UpgradeContainer.php +++ b/classes/UpgradeContainer.php @@ -367,9 +367,7 @@ public function getTwig() // Using independant template engine for 1.6 & 1.7 compatibility $loader = new Twig_Loader_Filesystem(); $loader->addPath(realpath(__DIR__.'/..').'/views/templates', 'ModuleAutoUpgrade'); - $twig = new Twig_Environment($loader, array( - 'cache' => $this->getProperty(self::TMP_PATH), - )); + $twig = new Twig_Environment($loader); $twig->addExtension(new TransFilterExtension($this->getTranslator())); $this->twig = $twig; From 10b9f1fcb460673dd33e46d357ef840089598ea8 Mon Sep 17 00:00:00 2001 From: Thomas Nabord Date: Thu, 28 Jun 2018 15:24:24 +0100 Subject: [PATCH 2/2] Use PrestaShop requirements in Uprade checklist --- classes/Twig/Block/UpgradeChecklist.php | 3 +++ classes/UpgradeSelfCheck.php | 32 +++++++++++++++++++++++++ views/templates/block/checklist.twig | 16 +++++++++++++ 3 files changed, 51 insertions(+) diff --git a/classes/Twig/Block/UpgradeChecklist.php b/classes/Twig/Block/UpgradeChecklist.php index 737f22dce..4e5b365f5 100644 --- a/classes/Twig/Block/UpgradeChecklist.php +++ b/classes/Twig/Block/UpgradeChecklist.php @@ -29,6 +29,7 @@ use PrestaShop\Module\AutoUpgrade\UpgradeSelfCheck; use PrestaShop\Module\AutoUpgrade\Tools14; +use Context; use Twig_Environment; /** @@ -113,6 +114,7 @@ public function render() 'moduleIsUpToDate' => $this->selfCheck->isModuleVersionLatest(), 'versionGreaterThan1_5_3' => version_compare(_PS_VERSION_, '1.5.3.0', '>'), 'adminToken' => Tools14::getAdminTokenLite('AdminModules'), + 'informationsLink' => Context::getContext()->link->getAdminLink('AdminInformation'), 'rootDirectoryIsWritable' => $this->selfCheck->isRootDirectoryWritable(), 'rootDirectoryWritableReport' => $this->selfCheck->getRootWritableReport(), 'adminDirectoryIsWritable' => $this->selfCheck->isAdminAutoUpgradeDirectoryWritable(), @@ -124,6 +126,7 @@ public function render() 'token' => $this->token, 'cachingIsDisabled' => $this->selfCheck->isCacheDisabled(), 'maxExecutionTime' => $this->selfCheck->getMaxExecutionTime(), + 'isPrestaShopReady' => $this->selfCheck->isPrestaShopReady(), ); return $this->twig->render('@ModuleAutoUpgrade/block/checklist.twig', $data); diff --git a/classes/UpgradeSelfCheck.php b/classes/UpgradeSelfCheck.php index eff6751bf..b19f73bd2 100644 --- a/classes/UpgradeSelfCheck.php +++ b/classes/UpgradeSelfCheck.php @@ -87,6 +87,11 @@ class UpgradeSelfCheck */ private $maxExecutionTime; + /** + * @var bool + */ + private $prestashopReady; + /** * @var string */ @@ -111,6 +116,7 @@ public function __construct(Upgrader $upgrader, $prodRootPath, $adminPath, $auto $this->safeModeDisabled = $this->checkSafeModeIsDisabled(); $this->moduleVersionIsLatest = $this->checkModuleVersionIsLastest($upgrader); $this->maxExecutionTime = $this->checkMaxExecutionTime(); + $this->prestashopReady = $this->runPrestaShopCoreChecks(); } /** @@ -209,6 +215,11 @@ public function getMaxExecutionTime() return $this->maxExecutionTime; } + public function isPrestaShopReady() + { + return $this->prestashopReady; + } + /** * Indicates if the self check status allows going ahead with the upgrade. * @@ -223,6 +234,7 @@ public function isOkForUpgrade() && $this->isShopDeactivated() && $this->isCacheDisabled() && $this->isModuleVersionLatest() + && $this->isPrestaShopReady() ); } @@ -308,4 +320,24 @@ private function checkMaxExecutionTime() { return (int) @ini_get('max_execution_time'); } + + /** + * Ask the core to run its tests, if available + * + * @return bool + */ + public function runPrestaShopCoreChecks() + { + if (!class_exists('ConfigurationTest')) { + return true; + } + + $defaultTests = ConfigurationTest::check(ConfigurationTest::getDefaultTests()); + foreach ($defaultTests as $testResult) { + if ($testResult !== "ok") { + return false; + } + } + return true; + } } diff --git a/views/templates/block/checklist.twig b/views/templates/block/checklist.twig index 954a0a538..b120531a4 100644 --- a/views/templates/block/checklist.twig +++ b/views/templates/block/checklist.twig @@ -114,6 +114,22 @@ {% endif %} + + + {% if isPrestaShopReady %} + {{ 'PrestaShop requirements are satisfied. '|trans }} + {% else %} + {{ 'PrestaShop requirements are not satisfied. '|trans }} {{ 'See details.'|trans }} + {% endif %} + + + {% if isPrestaShopReady %} + {{ icons.ok }} + {% else %} + {{ icons.warning }} + {% endif %} + +

{{ 'Please also make sure you make a full manual backup of your files and database.'|trans }}