Skip to content

Commit

Permalink
Merge pull request #705 from PrestaShop/dev
Browse files Browse the repository at this point in the history
Prepare release of v5.0.2
  • Loading branch information
M0rgan01 authored Jun 5, 2024
2 parents 1e2754a + e662922 commit b13a544
Show file tree
Hide file tree
Showing 84 changed files with 239,342 additions and 1,056 deletions.
27 changes: 26 additions & 1 deletion .github/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,35 @@ description: Test PrestaShop upgrade process
runs:
using: composite
steps:
- name: Get base version
id: get_base_version
shell: bash
run: |
case ${{ matrix.from }} in
1.6* | 1.7.[1-4]*)
echo "BASE_VERSION=7.1-apache" >> "$GITHUB_OUTPUT"
;;
1.7.[5-6]*)
echo "BASE_VERSION=7.2-apache" >> "$GITHUB_OUTPUT"
;;
1.7.7*)
echo "BASE_VERSION=7.3-apache" >> "$GITHUB_OUTPUT"
;;
1.7.8*)
echo "BASE_VERSION=7.4-apache" >> "$GITHUB_OUTPUT"
;;
8.0* | 8.1*)
echo "BASE_VERSION=8.1-apache" >> "$GITHUB_OUTPUT"
;;
*)
echo "BASE_VERSION=7.1-apache" >> "$GITHUB_OUTPUT"
;;
esac
- name: Build docker compose stack
env:
VERSION: ${{ matrix.from }}
BASE_VERSION: ${{ startsWith(matrix.from, '1.6') && '7.1-apache' || startsWith(matrix.from, '8.1') && '8.1-apache' || startsWith(matrix.from, '8.0') && '8.1-apache' || '7.2-apache' }}
BASE_VERSION: ${{ steps.get_base_version.outputs.BASE_VERSION }}
shell: bash
run: |
docker compose up -d
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/e2e_nightly_upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v4.1.3

- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16

Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
steps:

# Setup PrestaShop and Install Autoupgrade module
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v4.1.3

- run: |
cp -r .github .github_dev
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:

# Install Module with user interface
- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16

Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
ZIP_NAME: ${{ matrix.ps_target_version.filename }}
AUTOUPGRADE_VERSION: ${{ matrix.module_branch }}

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
name: Upload failed screenshots
if: ${{ always() }}
with:
Expand All @@ -140,7 +140,7 @@ jobs:
if: ${{ always() }}
run: ./tests/e2e/scripts/copy_reports.sh ${{ env.reports_directory }} ${{ matrix.ps_start_version }} ${{ matrix.ps_target_version.branch }} ${{ matrix.module_branch }}

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
name: Upload Mochawesome report
if: ${{ always() }}
with:
Expand All @@ -162,16 +162,16 @@ jobs:
fail-fast: false

steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v4.1.3

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
name: Download reports
with:
name: tests-reports-${{ matrix.ps_target_version.branch }}
path: ${{ env.reports_directory }}

- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 16

Expand All @@ -185,7 +185,7 @@ jobs:
run: npx mochawesome-merge "${{ env.reports_directory }}/*.json" -o "${{ env.reports_directory }}/${{ env.combined_report_name }}"
working-directory: ./tests/e2e

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
name: Upload combined report
with:
name: combined-report-${{ matrix.ps_target_version.branch }}
Expand All @@ -206,15 +206,15 @@ jobs:
fail-fast: false

steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v4.1.3

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
name: Download report
with:
name: combined-report-${{ matrix.ps_target_version.branch }}
path: ${{ env.reports_directory }}

- uses: google-github-actions/setup-gcloud@v0
- uses: google-github-actions/setup-gcloud@v2.1.0
name: Setup Cloud Sdk
with:
project_id: ${{ secrets.GC_PROJECT_ID }}
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/nightly_upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ jobs:
name: Set up matrix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v4.1.3
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
- id: set-matrix
run: echo "::set-output name=matrix::$(php ./.github/get_matrix.php)"
run: echo "matrix=$(php ./.github/get_matrix.php)" >> $GITHUB_OUTPUT
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
upgrade:
Expand All @@ -37,7 +37,7 @@ jobs:
outputs:
result: ${{ steps.export-result.outputs.result }}
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v4.1.3
- if: ${{ matrix.branch != 'dev' }}
run: |
cp -r .github .github_dev
Expand All @@ -59,7 +59,7 @@ jobs:
echo "${{ matrix.branch }}|${{matrix.from}}|${{matrix.ps-versions.branch}}|${{matrix.ps-versions.version}}|$START_DATE|$END_DATE|${{steps.upgrade-rollback.outcome}}" > ${{ matrix.branch }}_${{matrix.from}}_${{matrix.ps-versions.branch}}.txt
- name: Upload artifact
if: ${{ always() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.branch }}_${{matrix.from}}_${{matrix.ps-versions.branch}}
path: ${{ matrix.branch }}_${{matrix.from}}_${{matrix.ps-versions.branch}}.txt
Expand All @@ -74,14 +74,14 @@ jobs:
matrix:
ps-versions: ${{ fromJson(needs.get_matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/download-artifact@v2
- uses: actions/checkout@v4.1.3
- uses: actions/download-artifact@v4
with:
path: ./artifacts/
- name: Format results
run: php ./.github/get_results.php ${{matrix.ps-versions.branch}}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
uses: google-github-actions/setup-gcloud@v2.1.0
with:
project_id: ${{ secrets.GC_PROJECT_ID }}
service_account_key: ${{ secrets.GC_SERVICE_KEY }}
Expand Down
39 changes: 8 additions & 31 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3.1.0
uses: actions/checkout@v4.1.3

- name: PHP syntax checker 5.6
uses: prestashop/github-action-php-lint/5.6@master
Expand Down Expand Up @@ -53,10 +53,10 @@ jobs:
php-version: '5.6'

- name: Checkout
uses: actions/checkout@v3.1.0
uses: actions/checkout@v4.1.3

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4.0.2
with:
path: vendor
key: php-${{ hashFiles('composer.lock') }}
Expand All @@ -79,7 +79,7 @@ jobs:
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv, ext-zip
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v4.1.3
with:
fetch-depth: 0

Expand All @@ -95,35 +95,12 @@ jobs:
presta-versions: ['1.7.2.5', '1.7.3.4', '1.7.4.4', '1.7.5.1', '1.7.6', '1.7.7', '1.7.8', '8.0.0', 'latest']
steps:
- name: Checkout
uses: actions/checkout@v3.1.0
uses: actions/checkout@v4.1.3

# Add vendor folder in cache to make next builds faster
- name: Cache vendor folder
uses: actions/cache@v3
with:
path: vendor
key: php-${{ hashFiles('composer.lock') }}

# Add composer local folder in cache to make next builds faster
- name: Cache composer folder
uses: actions/cache@v3
with:
path: ~/.composer/cache
key: php-composer-cache
- run: composer install

- run: composer install
working-directory: ./tests

- name: Execute PHPStan on PrestaShop (Tag ${{ matrix.presta-versions }})
run: |
docker rm -f temp-ps || true
docker volume rm -f ps-volume || true
docker run -d --rm -v ps-volume:/var/www/html --name temp-ps prestashop/prestashop:${{ matrix.presta-versions }}
docker exec -t temp-ps rm -rf /var/www/html/modules/autoupgrade
docker build -t phpstan:php-7.4 ./tests/phpstan/
docker run --rm \
--volumes-from temp-ps \
-v $PWD:/var/www/html/modules/autoupgrade \
-e _PS_ROOT_DIR_=/var/www/html \
--workdir=/var/www/html/modules/autoupgrade \
phpstan:php-7.4 \
analyse --configuration=/var/www/html/modules/autoupgrade/tests/phpstan/phpstan-${{ matrix.presta-versions }}.neon
run: bash tests/phpstan/phpstan.sh ${{ matrix.presta-versions }} --error-format=github
4 changes: 2 additions & 2 deletions .github/workflows/upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ jobs:
upgrade:
strategy:
matrix:
from: ['1.7.6.9', '1.7.6.1', '1.7.7.0', '8.0.0', '8.1.0']
from: ['1.7.0.6', '1.7.6.9', '1.7.6.1', '1.7.7.0', '8.0.0', '8.1.0']
ps-versions:
- channel: minor
- channel: major
runs-on: ubuntu-latest
name: Upgrade
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v4.1.3
- name: Composer Install
run: composer install
- name: Upgrade & Rollback
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
nbproject

/vendor/
vendor/
/config_*.xml
.php_cs.cache
.idea
Expand Down
Binary file removed AdminSelfUpgrade.gif
Binary file not shown.
15 changes: 8 additions & 7 deletions 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 = '5.0.1';
$this->version = '5.0.2';
$this->need_instance = 1;

$this->bootstrap = true;
Expand Down Expand Up @@ -79,7 +79,10 @@ public function install()
$tab = new Tab();
$tab->class_name = 'AdminSelfUpgrade';
$tab->module = 'autoupgrade';
$tab->id_parent = (int) Tab::getIdFromClassName('AdminTools');

// We use DEFAULT to add Upgrade tab as a standalone tab in the back office menu
$tab->id_parent = (int) Tab::getIdFromClassName('DEFAULT');

foreach (Language::getLanguages(false) as $lang) {
$tab->name[(int) $lang['id_lang']] = '1-Click Upgrade';
}
Expand Down Expand Up @@ -140,9 +143,9 @@ public function hookDashboardZoneOne($params)
require_once __DIR__ . '/vendor/autoload.php';

$upgradeContainer = new \PrestaShop\Module\AutoUpgrade\UpgradeContainer(_PS_ROOT_DIR_, _PS_ADMIN_DIR_);
$upgrader = $upgradeContainer->getUpgrader();
$upgradeSelfCheck = new \PrestaShop\Module\AutoUpgrade\UpgradeSelfCheck(
$upgrader,
$upgradeContainer->getUpgrader(),
$upgradeContainer->getPrestaShopConfiguration(),
_PS_ROOT_DIR_,
_PS_ADMIN_DIR_,
__DIR__
Expand All @@ -166,9 +169,7 @@ public function hookDashboardZoneOne($params)

public function getContent()
{
global $cookie;
header('Location: index.php?controller=AdminSelfUpgrade&token=' . md5(pSQL(_COOKIE_KEY_ . 'AdminSelfUpgrade' . (int) Tab::getIdFromClassName('AdminSelfUpgrade') . (int) $cookie->id_employee)));
exit;
Tools::redirectAdmin($this->context->link->getAdminLink('AdminSelfUpgrade'));
}

/**
Expand Down
3 changes: 2 additions & 1 deletion classes/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ public function errorHandler($errno, $errstr, $errfile, $errline)
public function fatalHandler()
{
$lastError = error_get_last();
$trace = isset($lastError['backtrace']) ? var_export($lastError['backtrace'], true) : null;
if ($lastError && in_array($lastError['type'], [E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR], true)) {
// @phpstan-ignore isset.offset (Need to check if xdebug still defines this key)
$trace = isset($lastError['backtrace']) ? var_export($lastError['backtrace'], true) : null;
$this->report($lastError['file'], $lastError['line'], Logger::CRITICAL, $lastError['message'], $trace, true);
}
}
Expand Down
5 changes: 1 addition & 4 deletions classes/PrestashopConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,12 @@ class PrestashopConfiguration
{
// Variables used for cache
private $moduleVersion;
private $allowed_array = [];

// Variables from main class
private $autoupgradeDir;
private $psRootDir;

public function __construct($moduleDir, $psRootDir)
public function __construct($psRootDir)
{
$this->autoupgradeDir = $moduleDir;
$this->psRootDir = $psRootDir;
}

Expand Down
8 changes: 5 additions & 3 deletions classes/TaskRunner/Miscellaneous/CheckFilesVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeFileNames;
use PrestaShop\Module\AutoUpgrade\TaskRunner\AbstractTask;
use PrestaShop\Module\AutoUpgrade\UpgradeContainer;

/**
* List the files modified in the current installation regards to the original version.
Expand All @@ -39,8 +40,9 @@ public function run()
{
// do nothing after this request (see javascript function doAjaxRequest )
$this->next = '';
$upgrader = $this->container->getUpgrader();
$changedFileList = $upgrader->getChangedFilesList();
$checksumCompare = $this->container->getChecksumCompare();
$currentPrestaShopVersion = $this->container->getProperty(UpgradeContainer::PS_VERSION);
$changedFileList = $checksumCompare->getTamperedFilesOnShop($currentPrestaShopVersion);

if ($changedFileList === false) {
$this->nextParams['status'] = 'error';
Expand All @@ -55,7 +57,7 @@ public function run()
}
}

if ($upgrader->isAuthenticPrestashopVersion() === true) {
if ($checksumCompare->isAuthenticPrestashopVersion($currentPrestaShopVersion)) {
$this->nextParams['status'] = 'ok';
$this->nextParams['msg'] = $this->translator->trans('Core files are ok', [], 'Modules.Autoupgrade.Admin');
} else {
Expand Down
Loading

0 comments on commit b13a544

Please sign in to comment.