Skip to content

Commit

Permalink
Merge pull request #884 from PrestaShop/6.x
Browse files Browse the repository at this point in the history
Prepare release of 6.2.0 by merging 6.x in master
  • Loading branch information
Quetzacoalt91 authored Sep 17, 2024
2 parents 1d55a5a + 3c8706e commit 425ec7c
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 27 deletions.
2 changes: 1 addition & 1 deletion autoupgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct()
$this->name = 'autoupgrade';
$this->tab = 'administration';
$this->author = 'PrestaShop';
$this->version = '6.1.0';
$this->version = '6.2.0';
$this->need_instance = 1;
$this->module_key = '926bc3e16738b7b834f37fc63d59dcf8';

Expand Down
2 changes: 1 addition & 1 deletion classes/Twig/Block/UpgradeChecklist.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function getTemplateVars(): array
'token' => $this->token,
'cachingIsDisabled' => $this->selfCheck->isCacheDisabled(),
'maxExecutionTime' => $this->selfCheck->getMaxExecutionTime(),
'phpRequirementsState' => $this->selfCheck->getPhpRequirementsState(),
'phpRequirementsState' => $this->selfCheck->getPhpRequirementsState(PHP_VERSION_ID),
'phpCompatibilityRange' => $this->selfCheck->getPhpCompatibilityRange(),
'checkApacheModRewrite' => $this->selfCheck->isApacheModRewriteEnabled(),
'notLoadedPhpExtensions' => $this->selfCheck->getNotLoadedPhpExtensions(),
Expand Down
14 changes: 10 additions & 4 deletions classes/UpgradeSelfCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public function isOkForUpgrade(): bool
&& ($this->isShopDeactivated() || $this->isLocalEnvironment())
&& $this->isCacheDisabled()
&& $this->isModuleVersionLatest()
&& $this->getPhpRequirementsState() !== $this::PHP_REQUIREMENTS_INVALID
&& $this->getPhpRequirementsState(PHP_VERSION_ID) !== $this::PHP_REQUIREMENTS_INVALID
&& $this->isShopVersionMatchingVersionInDatabase()
&& $this->isApacheModRewriteEnabled()
&& $this->checkKeyGeneration()
Expand Down Expand Up @@ -457,9 +457,11 @@ public function getPhpCompatibilityRange(): ?array
}

/**
* @param int $currentVersionId
*
* @return self::PHP_REQUIREMENTS_*
*/
public function getPhpRequirementsState(): int
public function getPhpRequirementsState($currentVersionId): int
{
$phpCompatibilityRange = $this->getPhpCompatibilityRange();

Expand All @@ -469,9 +471,13 @@ public function getPhpRequirementsState(): int

$versionMin = VersionUtils::getPhpVersionId($phpCompatibilityRange['php_min_version']);
$versionMax = VersionUtils::getPhpVersionId($phpCompatibilityRange['php_max_version']);
$currentVersion = VersionUtils::getPhpMajorMinorVersionId();

if ($currentVersion >= $versionMin && $currentVersion <= $versionMax) {
$versionMinWithoutPatch = VersionUtils::getPhpMajorMinorVersionId($versionMin);
$versionMaxWithoutPatch = VersionUtils::getPhpMajorMinorVersionId($versionMax);

$currentVersion = VersionUtils::getPhpMajorMinorVersionId($currentVersionId);

if ($currentVersion >= $versionMinWithoutPatch && $currentVersion <= $versionMaxWithoutPatch) {
return self::PHP_REQUIREMENTS_VALID;
}

Expand Down
6 changes: 3 additions & 3 deletions classes/VersionUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ public static function getPhpVersionId($version)
}

/**
* @param int $phpVersionId
*
* @return int
*/
public static function getPhpMajorMinorVersionId()
public static function getPhpMajorMinorVersionId($phpVersionId)
{
$phpVersionId = PHP_VERSION_ID;

$major = (int) ($phpVersionId / 10000);
$minor = (int) (($phpVersionId % 10000) / 100);

Expand Down
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>autoupgrade</name>
<displayName><![CDATA[1-Click Upgrade]]></displayName>
<version><![CDATA[6.1.0]]></version>
<version><![CDATA[6.2.0]]></version>
<description><![CDATA[Upgrade to the latest version of PrestaShop in a few clicks, thanks to this automated method.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[administration]]></tab>
Expand Down
77 changes: 77 additions & 0 deletions tests/unit/UpgradeSelfCheckTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/

namespace unit;

use PHPUnit\Framework\TestCase;
use PrestaShop\Module\AutoUpgrade\UpgradeSelfCheck;

class UpgradeSelfCheckTest extends TestCase
{
/** @var UpgradeSelfCheck */
private $upgradeSelfCheck;

public function setUp()
{
if (PHP_VERSION_ID >= 80000) {
$this->markTestSkipped('An issue with this version of PHPUnit and PHP 8+ prevents this test to run.');
}

$this->upgradeSelfCheck = $this->getMockBuilder(UpgradeSelfCheck::class)
->disableOriginalConstructor()
->setMethods(['getPhpCompatibilityRange'])
->getMock();
}

public function testInvalidCompatibilityRange()
{
$this->upgradeSelfCheck->method('getPhpCompatibilityRange')
->willReturn(['php_min_version' => '7.1.0', 'php_max_version' => '7.4.0']);

$this->assertEquals(UpgradeSelfCheck::PHP_REQUIREMENTS_INVALID, $this->upgradeSelfCheck->getPhpRequirementsState(80000));
}

public function testValidCompatibilityRange()
{
$this->upgradeSelfCheck->method('getPhpCompatibilityRange')
->willReturn(['php_min_version' => '7.1.0', 'php_max_version' => '7.4.0']);

$this->assertEquals(UpgradeSelfCheck::PHP_REQUIREMENTS_VALID, $this->upgradeSelfCheck->getPhpRequirementsState(70300));

$this->upgradeSelfCheck->method('getPhpCompatibilityRange')
->willReturn(['php_min_version' => '7.2.5', 'php_max_version' => '8.1']);

$this->assertEquals(UpgradeSelfCheck::PHP_REQUIREMENTS_VALID, $this->upgradeSelfCheck->getPhpRequirementsState(70213));
}

public function testUnknownCompatibilityRange()
{
$this->upgradeSelfCheck->method('getPhpCompatibilityRange')
->willReturn(null);

$this->assertEquals(UpgradeSelfCheck::PHP_REQUIREMENTS_UNKNOWN, $this->upgradeSelfCheck->getPhpRequirementsState(70300));
}
}
12 changes: 10 additions & 2 deletions tests/unit/VersionUtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ public function testGetPhpVersionId()
$version = VersionUtils::getPhpVersionId('7.1');

$this->assertSame(70100, $version);

$version = VersionUtils::getPhpVersionId('7.2.18');

$this->assertSame(70218, $version);

$version = VersionUtils::getPhpVersionId('7.2.5');

$this->assertSame(70205, $version);
}

public function testGetPhpVersionIdFailForBadType()
Expand All @@ -98,9 +106,9 @@ public function testGetPhpVersionIdFailForNonNumericValue()

public function testGetPhpMajorMinorVersionId()
{
$version = VersionUtils::getPhpMajorMinorVersionId();
$version = VersionUtils::getPhpMajorMinorVersionId(70218);

$this->assertSame(PHP_MAJOR_VERSION * 10000 + PHP_MINOR_VERSION * 100, $version);
$this->assertSame(70200, $version);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions translations/ModulesAutoupgradeAdmin.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
<trans-unit id="8d8e0207549d32c6f864246403034279" approved="yes">
<source>Core files are ok</source>
<target state="final">Archivos del núcleo están OK</target>
<note>Line: 65</note>
<note>Line: 61</note>
</trans-unit>
<trans-unit id="1642bf84232919297d598b2a66b3a894" approved="yes">
<source>%modificationscount% file modifications have been detected, including %coremodifications% from core and native modules:</source>
<target state="final">Se han detectado %modificationscount% modificaciones en los archivos, incluyendo %coremodifications% de núcleo y módulos nativos:</target>
<note>Line: 69</note>
<note>Line: 65</note>
</trans-unit>
</body>
</file>
Expand Down
4 changes: 2 additions & 2 deletions translations/ModulesAutoupgradeAdmin.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
<trans-unit id="8d8e0207549d32c6f864246403034279" approved="yes">
<source>Core files are ok</source>
<target state="final">Les fichiers du coeur sont ok</target>
<note>Line: 65</note>
<note>Line: 61</note>
</trans-unit>
<trans-unit id="1642bf84232919297d598b2a66b3a894" approved="yes">
<source>%modificationscount% file modifications have been detected, including %coremodifications% from core and native modules:</source>
<target state="final">%modificationscount% modifications de fichiers ont été détectées, dont %coremodifications% fichiers natifs (coeur et modules) :</target>
<note>Line: 69</note>
<note>Line: 65</note>
</trans-unit>
</body>
</file>
Expand Down
6 changes: 3 additions & 3 deletions translations/ModulesAutoupgradeAdmin.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
<trans-unit id="8d8e0207549d32c6f864246403034279" approved="yes">
<source>Core files are ok</source>
<target state="final">Core file ok</target>
<note>Line: 65</note>
<note>Line: 61</note>
</trans-unit>
<trans-unit id="1642bf84232919297d598b2a66b3a894" approved="yes">
<source>%modificationscount% file modifications have been detected, including %coremodifications% from core and native modules:</source>
<target state="final">Sono state individuate %modificationscount% modifiche di file, incluse %coremodifications% modifiche del core e dei moduli nativi:</target>
<note>Line: 69</note>
<note>Line: 65</note>
</trans-unit>
</body>
</file>
Expand Down Expand Up @@ -612,7 +612,7 @@ Comment: directory already exists</note>
</trans-unit>
<trans-unit id="da652b8ece8ba2da84d5f5116f6ef63e" approved="yes">
<source>MD5 hash will be checked against %s</source>
<target state="final">L'hask MD% sarà confrontato con %s</target>
<target state="final">L'hask MD5 sarà confrontato con %s</target>
<note>Line: 94</note>
</trans-unit>
</body>
Expand Down
4 changes: 2 additions & 2 deletions translations/ModulesAutoupgradeAdmin.nl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
<trans-unit id="8d8e0207549d32c6f864246403034279" approved="yes">
<source>Core files are ok</source>
<target state="final">Core bestanden zijn ok</target>
<note>Line: 65</note>
<note>Line: 61</note>
</trans-unit>
<trans-unit id="1642bf84232919297d598b2a66b3a894" approved="yes">
<source>%modificationscount% file modifications have been detected, including %coremodifications% from core and native modules:</source>
<target state="final">%modificationscount% bestandswijzigingen zijn gevonden, waaronder %coremodifications% in core en native modules:</target>
<note>Line: 69</note>
<note>Line: 65</note>
</trans-unit>
</body>
</file>
Expand Down
4 changes: 2 additions & 2 deletions translations/ModulesAutoupgradeAdmin.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
<trans-unit id="8d8e0207549d32c6f864246403034279" approved="yes">
<source>Core files are ok</source>
<target state="final">Pliki główne są OK</target>
<note>Line: 65</note>
<note>Line: 61</note>
</trans-unit>
<trans-unit id="1642bf84232919297d598b2a66b3a894" approved="yes">
<source>%modificationscount% file modifications have been detected, including %coremodifications% from core and native modules:</source>
<target state="final">Wykryto %modificationscount% modyfikacji plików, włączając %coremodifications% z głównej części i wbudowanych modułów:</target>
<note>Line: 69</note>
<note>Line: 65</note>
</trans-unit>
</body>
</file>
Expand Down
4 changes: 2 additions & 2 deletions translations/ModulesAutoupgradeAdmin.pt.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
<trans-unit id="8d8e0207549d32c6f864246403034279" approved="yes">
<source>Core files are ok</source>
<target state="final">Os ficheiros do núcleo estão OK</target>
<note>Line: 65</note>
<note>Line: 61</note>
</trans-unit>
<trans-unit id="1642bf84232919297d598b2a66b3a894" approved="yes">
<source>%modificationscount% file modifications have been detected, including %coremodifications% from core and native modules:</source>
<target state="final">Foram detetadas %modificationscount% alterações nos ficheiros, incluindo %coremodifications% nos ficheiros do núcleo e nos módulos nativos:</target>
<note>Line: 69</note>
<note>Line: 65</note>
</trans-unit>
</body>
</file>
Expand Down
4 changes: 2 additions & 2 deletions translations/ModulesAutoupgradeAdmin.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
<trans-unit id="8d8e0207549d32c6f864246403034279" approved="yes">
<source>Core files are ok</source>
<target state="final">Основные файлы в порядке</target>
<note>Line: 65</note>
<note>Line: 61</note>
</trans-unit>
<trans-unit id="1642bf84232919297d598b2a66b3a894" approved="yes">
<source>%modificationscount% file modifications have been detected, including %coremodifications% from core and native modules:</source>
<target state="final">Обнаружено измененных файлов: %modificationscount%, включая %coremodifications% из ядра и нативных модулей:</target>
<note>Line: 69</note>
<note>Line: 65</note>
</trans-unit>
</body>
</file>
Expand Down

0 comments on commit 425ec7c

Please sign in to comment.