Skip to content

Commit 3d17517

Browse files
authored
Merge pull request #112 from Progi1984/dev
Release 4.1.1
2 parents 735c6ee + eb849b3 commit 3d17517

27 files changed

Lines changed: 198 additions & 78 deletions

.github/workflows/build-release.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
name: Build & Release draft
2-
1+
name: Build
32
on: [push, pull_request]
43

54
jobs:
@@ -9,19 +8,21 @@ jobs:
98
steps:
109
- name: Checkout
1110
uses: actions/checkout@v2.0.0
12-
1311
- name: Install composer dependencies
1412
run: composer install --no-dev -o
15-
1613
- name: Clean-up project
1714
uses: PrestaShopCorp/github-action-clean-before-deploy@v1.0
18-
15+
- name: Prepare auto-index tool
16+
run: |
17+
composer global require prestashop/autoindex
18+
- name: Generate index.php
19+
run: |
20+
~/.composer/vendor/bin/autoindex
1921
- name: Create & upload artifact
2022
uses: actions/upload-artifact@v1
2123
with:
2224
name: ${{ github.event.repository.name }}
2325
path: ../
24-
2526
update_release_draft:
2627
runs-on: ubuntu-latest
2728
needs: [deploy]
@@ -31,29 +32,25 @@ jobs:
3132
uses: actions/download-artifact@v1
3233
with:
3334
name: ${{ github.event.repository.name }}
34-
3535
- id: release_info
3636
uses: toolmantim/release-drafter@v5
3737
env:
3838
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39-
4039
- name: Prepare for Release
4140
run: |
4241
cd ${{ github.event.repository.name }}
4342
zip -r ${{ github.event.repository.name }}.zip ${{ github.event.repository.name }}
44-
4543
- name: Clean existing assets
4644
shell: bash
4745
run: |
4846
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
4947
assets=`bin/hub api -t repos/${{ github.repository }}/releases/${{ steps.release_info.outputs.id }}/assets | awk '/\].url/ { print $2 }'`
5048
for asset in $assets
5149
do
52-
bin/hub api -X DELETE $asset
50+
bin/hub api -X DELETE $asset
5351
done
5452
env:
5553
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56-
5754
- name: Publish to GitHub Release
5855
uses: actions/upload-release-asset@v1.0.1
5956
env:

.github/workflows/php.yml

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,81 @@
11
name: PHP tests
22
on: [push, pull_request]
33
jobs:
4+
# Check there is no syntax errors in the project
45
php-linter:
5-
name: PHP Syntax check 5.6|7.2|7.3
6+
name: PHP Syntax check 5.6 => 8.1
67
runs-on: ubuntu-latest
78
steps:
89
- name: Checkout
910
uses: actions/checkout@v2.0.0
11+
1012
- name: PHP syntax checker 5.6
1113
uses: prestashop/github-action-php-lint/5.6@master
14+
1215
- name: PHP syntax checker 7.2
1316
uses: prestashop/github-action-php-lint/7.2@master
17+
1418
- name: PHP syntax checker 7.3
1519
uses: prestashop/github-action-php-lint/7.3@master
20+
21+
- name: PHP syntax checker 7.4
22+
uses: prestashop/github-action-php-lint/7.4@master
23+
24+
- name: PHP syntax checker 8.0
25+
uses: prestashop/github-action-php-lint/8.0@master
26+
27+
- name: PHP syntax checker 8.1
28+
uses: prestashop/github-action-php-lint/8.1@master
29+
30+
# Check the PHP code follow the coding standards
1631
php-cs-fixer:
1732
name: PHP-CS-Fixer
1833
runs-on: ubuntu-latest
1934
steps:
35+
- name: Setup PHP
36+
uses: shivammathur/setup-php@v2
37+
with:
38+
php-version: '7.4'
39+
2040
- name: Checkout
2141
uses: actions/checkout@v2.0.0
42+
43+
- name: Cache dependencies
44+
uses: actions/cache@v2
45+
with:
46+
path: vendor
47+
key: php-${{ hashFiles('composer.lock') }}
48+
49+
- name: Install dependencies
50+
run: composer install
51+
2252
- name: Run PHP-CS-Fixer
23-
uses: prestashopcorp/github-action-php-cs-fixer@master
53+
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff --using-cache=no --diff-format udiff
54+
55+
# Run PHPStan against the module and a PrestaShop release
2456
phpstan:
2557
name: PHPStan
2658
runs-on: ubuntu-latest
2759
strategy:
2860
matrix:
29-
presta-versions: ['latest', '1.7.0.3', '1.6.1.21','1.6.1.0']
61+
presta-versions: ['1.6.1.18', '1.7.1.2', '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', 'latest']
3062
steps:
63+
- name: Setup PHP
64+
uses: shivammathur/setup-php@v2
65+
with:
66+
php-version: '7.4'
67+
3168
- name: Checkout
3269
uses: actions/checkout@v2.0.0
3370

71+
# Add vendor folder in cache to make next builds faster
3472
- name: Cache vendor folder
3573
uses: actions/cache@v1
3674
with:
3775
path: vendor
3876
key: php-${{ hashFiles('composer.lock') }}
3977

78+
# Add composer local folder in cache to make next builds faster
4079
- name: Cache composer folder
4180
uses: actions/cache@v1
4281
with:
@@ -45,14 +84,6 @@ jobs:
4584

4685
- run: composer install
4786

48-
- name: Pull PrestaShop files (Tag ${{ matrix.presta-versions }})
49-
run: docker run -tid --rm -v ps-volume:/var/www/html --name temp-ps prestashop/prestashop:${{ matrix.presta-versions }}
50-
51-
- name: Select .neon file to run with PHPStan
52-
id: neon
53-
run: |
54-
PS_VERSION=$(docker exec temp-ps bash -c 'echo "$PS_VERSION"')
55-
[[ "${PS_VERSION:0:3}" != '1.7' ]] && echo ::set-output name=filename::phpstan-PS-1.6.neon || echo ::set-output name=filename::phpstan-PS-1.7.neon
56-
57-
- name : Run PHPStan
58-
run: docker run --rm --volumes-from temp-ps -v $PWD:/web/module -e _PS_ROOT_DIR_=/var/www/html --workdir=/web/module phpstan/phpstan:0.12 analyse --configuration=/web/module/tests/phpstan/${{steps.neon.outputs.filename}}
87+
# Docker images prestashop/prestashop may be used, even if the shop remains uninstalled
88+
- name: Execute PHPStan on PrestaShop (Tag ${{ matrix.presta-versions }})
89+
run: ./tests/phpstan.sh ${{ matrix.presta-versions }}
File renamed without changes.

classes/Handler/ModuleHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function isModuleEnabled($moduleName)
3333
{
3434
$module = Module::getInstanceByName($moduleName);
3535

36-
if (false === $module) {
36+
if (!($module instanceof Module)) {
3737
return false;
3838
}
3939

@@ -78,7 +78,7 @@ public function uninstallModule($moduleName)
7878

7979
$oldModule = Module::getInstanceByName($moduleName);
8080

81-
if (false === $oldModule) {
81+
if (!($oldModule instanceof Module)) {
8282
return false;
8383
}
8484

classes/Hook/HookDisplayBackOfficeHeader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function run()
9090
if (!empty($transaction)) {
9191
$ganalyticsRepository->updateData(
9292
[
93-
'date_add' => 'NOW()',
93+
'date_add' => ['value' => 'NOW()', 'type' => 'sql'],
9494
'sent' => 1,
9595
],
9696
'id_order = ' . (int) $row['id_order'] . ' AND id_shop = ' . (int) $this->context->shop->id

classes/Hook/HookDisplayFooter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function run()
8787

8888
$listing = $this->context->smarty->getTemplateVars('listing');
8989
$productWrapper = new ProductWrapper($this->context);
90-
$products = $productWrapper->wrapProductList($listing['products'], [], true);
90+
$products = $productWrapper->wrapProductList(isset($listing['products']) ? $listing['products'] : [], [], true);
9191

9292
if ($controller_name == 'order' || $controller_name == 'orderopc') {
9393
$this->module->js_state = 1;

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
"email": "contact@prestashop.com"
1010
}
1111
],
12+
"require": {
13+
"php": ">=5.6"
14+
},
15+
"require-dev": {
16+
"prestashop/php-dev-tools": "3.*"
17+
},
1218
"config": {
1319
"preferred-install": "dist",
1420
"optimize-autoloader": true,
@@ -17,12 +23,6 @@
1723
"php": "5.6"
1824
}
1925
},
20-
"require": {
21-
"php": ">=5.6"
22-
},
23-
"require-dev": {
24-
"prestashop/php-dev-tools": "3.*"
25-
},
2626
"autoload": {
2727
"classmap": [
2828
"ps_googleanalytics.php",
@@ -32,4 +32,4 @@
3232
},
3333
"type": "prestashop-module",
3434
"author": "PrestaShop"
35-
}
35+
}

controllers/admin/AdminGanalyticsAjax.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function init()
3333
(new GanalyticsRepository())->updateData(
3434
[
3535
'sent' => 1,
36-
'date_add' => 'NOW()',
36+
'date_add' => ['value' => 'NOW()', 'type' => 'sql'],
3737
],
3838
'id_order = ' . $orderId
3939
);

ps_googleanalytics.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
exit;
2222
}
2323

24-
require_once __DIR__ . '/vendor/autoload.php';
24+
$autoloadPath = __DIR__ . '/vendor/autoload.php';
25+
if (file_exists($autoloadPath)) {
26+
require_once $autoloadPath;
27+
}
2528

2629
class Ps_Googleanalytics extends Module
2730
{

tests/index.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* 2007-2020 PrestaShop and Contributors
3+
* 2007-2020 PrestaShop SA and Contributors
44
*
55
* NOTICE OF LICENSE
66
*
@@ -12,12 +12,18 @@
1212
* obtain it through the world-wide-web, please send an email
1313
* to license@prestashop.com so we can send you a copy immediately.
1414
*
15+
* DISCLAIMER
16+
*
17+
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
18+
* versions in the future. If you wish to customize PrestaShop for your
19+
* needs please refer to https://www.prestashop.com for more information.
20+
*
1521
* @author PrestaShop SA <contact@prestashop.com>
1622
* @copyright 2007-2020 PrestaShop SA and Contributors
1723
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
1824
* International Registered Trademark & Property of PrestaShop SA
1925
*/
20-
header('Expires: Mon, 26 Jul 1998 05:00:00 GMT');
26+
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
2127
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
2228

2329
header('Cache-Control: no-store, no-cache, must-revalidate');

0 commit comments

Comments
 (0)