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

Use Prestashop requirements in Upgrade check list #89

Merged
merged 2 commits into from Jun 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions classes/Twig/Block/UpgradeChecklist.php
Expand Up @@ -29,6 +29,7 @@

use PrestaShop\Module\AutoUpgrade\UpgradeSelfCheck;
use PrestaShop\Module\AutoUpgrade\Tools14;
use Context;
use Twig_Environment;

/**
Expand Down Expand Up @@ -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(),
Expand All @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions classes/UpgradeContainer.php
Expand Up @@ -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;
Expand Down
32 changes: 32 additions & 0 deletions classes/UpgradeSelfCheck.php
Expand Up @@ -87,6 +87,11 @@ class UpgradeSelfCheck
*/
private $maxExecutionTime;

/**
* @var bool
*/
private $prestashopReady;

/**
* @var string
*/
Expand All @@ -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();
}

/**
Expand Down Expand Up @@ -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.
*
Expand All @@ -223,6 +234,7 @@ public function isOkForUpgrade()
&& $this->isShopDeactivated()
&& $this->isCacheDisabled()
&& $this->isModuleVersionLatest()
&& $this->isPrestaShopReady()
);
}

Expand Down Expand Up @@ -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;
}
}
16 changes: 16 additions & 0 deletions views/templates/block/checklist.twig
Expand Up @@ -114,6 +114,22 @@
{% endif %}
</td>
</tr>
<tr>
<td>
{% if isPrestaShopReady %}
{{ 'PrestaShop requirements are satisfied. '|trans }}
{% else %}
{{ 'PrestaShop requirements are not satisfied. '|trans }} <a href="{{ informationsLink }}">{{ 'See details.'|trans }}</a>
{% endif %}
</td>
<td>
{% if isPrestaShopReady %}
{{ icons.ok }}
{% else %}
{{ icons.warning }}
{% endif %}
</td>
</tr>
</table>
<br>
<p class="alert alert-info">{{ 'Please also make sure you make a full manual backup of your files and database.'|trans }}</p>
Expand Down