Skip to content

Commit

Permalink
Merge pull request #105 from PrestaShop/dev
Browse files Browse the repository at this point in the history
Release 2.3.2
  • Loading branch information
kpodemski authored Feb 2, 2022
2 parents e23a597 + fd68123 commit e9f3a2e
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 82 deletions.
153 changes: 81 additions & 72 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,75 +1,84 @@
name: PHP tests
on: [push, pull_request]
jobs:
# Check there is no syntax errors in the project
php-linter:
name: PHP Syntax check 5.6|7.2|7.3
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]

- name: PHP syntax checker 5.6
uses: prestashop/github-action-php-lint/5.6@master

- name: PHP syntax checker 7.2
uses: prestashop/github-action-php-lint/7.2@master

- name: PHP syntax checker 7.3
uses: prestashop/github-action-php-lint/7.3@master

# Check the PHP code follow the coding standards
php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'

- name: Checkout
uses: actions/[email protected]

- name: Cache dependencies
uses: actions/cache@v2
with:
path: vendor
key: php-${{ hashFiles('composer.lock') }}

- name: Install dependencies
run: composer install

- name: Run PHP-CS-Fixer
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff --using-cache=no --diff-format udiff

# Run PHPStan against the module and a PrestaShop release
phpstan:
name: PHPStan
runs-on: ubuntu-latest
strategy:
matrix:
presta-versions: ['1.7.6.9', 'latest']
steps:
- name: Checkout
uses: actions/[email protected]

# Add vendor folder in cache to make next builds faster
- name: Cache vendor folder
uses: actions/cache@v1
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@v1
with:
path: ~/.composer/cache
key: php-composer-cache

- run: composer install

# Docker images prestashop/prestashop may be used, even if the shop remains uninstalled
- name: Execute PHPStan on PrestaShop (Tag ${{ matrix.presta-versions }})
run: ./tests/php/phpstan.sh ${{ matrix.presta-versions }}
# Check there is no syntax errors in the project
php-linter:
name: PHP Syntax check 5.6 => 8.1
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]

- name: PHP syntax checker 5.6
uses: prestashop/github-action-php-lint/5.6@master

- name: PHP syntax checker 7.2
uses: prestashop/github-action-php-lint/7.2@master

- name: PHP syntax checker 7.3
uses: prestashop/github-action-php-lint/7.3@master

- name: PHP syntax checker 7.4
uses: prestashop/github-action-php-lint/7.4@master

- name: PHP syntax checker 8.0
uses: prestashop/github-action-php-lint/8.0@master

- name: PHP syntax checker 8.1
uses: prestashop/github-action-php-lint/8.1@master

# Check the PHP code follow the coding standards
php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'

- name: Checkout
uses: actions/[email protected]

- name: Cache dependencies
uses: actions/cache@v2
with:
path: vendor
key: php-${{ hashFiles('composer.lock') }}

- name: Install dependencies
run: composer install

- name: Run PHP-CS-Fixer
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff --using-cache=no --diff-format udiff

# Run PHPStan against the module and a PrestaShop release
phpstan:
name: PHPStan
runs-on: ubuntu-latest
strategy:
matrix:
presta-versions: ['1.7.6', '1.7.7', '1.7.8', 'latest']
steps:
- name: Checkout
uses: actions/[email protected]

# Add vendor folder in cache to make next builds faster
- name: Cache vendor folder
uses: actions/cache@v1
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@v1
with:
path: ~/.composer/cache
key: php-composer-cache

- run: composer install

# Docker images prestashop/prestashop may be used, even if the shop remains uninstalled
- name: Execute PHPStan on PrestaShop (Tag ${{ matrix.presta-versions }})
run: ./tests/php/phpstan.sh ${{ matrix.presta-versions }}
8 changes: 4 additions & 4 deletions MailAlert.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static function customerHasNotification($id_customer, $id_product, $id_pr
AND `id_product_attribute` = ' . (int) $id_product_attribute . '
AND `id_shop` = ' . (int) $id_shop;

return count(Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql));
return count(Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->executeS($sql));
}

public static function deleteAlert($id_customer, $customer_email, $id_product, $id_product_attribute, $id_shop = null)
Expand Down Expand Up @@ -280,7 +280,7 @@ public static function getProducts($customer, $id_lang)
AND (ma.`id_customer` = ' . (int) $customer->id . ' OR ma.`customer_email` = \'' . pSQL($customer->email) . '\')
AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestriction(false, 'ma');

return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
return Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->executeS($sql);
}

/*
Expand All @@ -299,7 +299,7 @@ public static function getProductAttributeCombination($id_product_attribute, $id
' . Shop::addSqlAssociation('product_attribute', 'pa') . '
WHERE pac.`id_product_attribute` = ' . (int) $id_product_attribute;

return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
return Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->executeS($sql);
}

/*
Expand All @@ -312,6 +312,6 @@ public static function getCustomers($id_product, $id_product_attribute)
FROM `' . _DB_PREFIX_ . self::$definition['table'] . '`
WHERE `id_product` = ' . (int) $id_product . ' AND `id_product_attribute` = ' . (int) $id_product_attribute;

return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
return Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->executeS($sql);
}
}
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>ps_emailalerts</name>
<displayName><![CDATA[Mail alerts]]></displayName>
<version><![CDATA[2.3.0]]></version>
<version><![CDATA[2.3.2]]></version>
<description><![CDATA[Sends e-mail notifications to customers and merchants regarding stock and order modifications.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[administration]]></tab>
Expand Down
9 changes: 7 additions & 2 deletions ps_emailalerts.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function __construct()
{
$this->name = 'ps_emailalerts';
$this->tab = 'administration';
$this->version = '2.3.1';
$this->version = '2.3.2';
$this->author = 'PrestaShop';
$this->need_instance = 0;

Expand Down Expand Up @@ -292,12 +292,17 @@ public function getAllMessages($id)
*
* @param Context $context
*
* @return \PrestaShop\PrestaShop\Core\Localization\Locale
* @return \PrestaShop\PrestaShop\Core\Localization\Locale|null
*
* @throws Exception
*/
public static function getContextLocale(Context $context)
{
$locale = $context->getCurrentLocale();
if (null !== $locale) {
return $locale;
}

$containerFinder = new \PrestaShop\PrestaShop\Adapter\ContainerFinder($context);
$container = $containerFinder->getContainer();
if (null === $context->container) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ includes:

parameters:
ignoreErrors:
- '~^Parameter #1 \$share of static method ShopCore::getContextListShopID\(\) expects string, false given\.$~'
- '~^Parameter #1 \$share of static method ShopCore::addSqlRestriction\(\) expects int, false given\.$~'
- '~^Parameter #4 \$templateVars of static method MailCore::send\(\) expects string, array<string, (mixed|int|string|\|)+> given\.$~'
- '~^Parameter #1 \$id of class Customer constructor expects null, int given\.$~'
7 changes: 7 additions & 0 deletions tests/php/phpstan/phpstan-1.7.7.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
includes:
- %currentWorkingDirectory%/tests/php/phpstan/phpstan.neon

parameters:
ignoreErrors:
- '#Parameter \#1 \$share of static method ShopCore\:\:getContextListShopID\(\) expects string, false given.#'
- '#Parameter \#1 \$share of static method ShopCore\:\:addSqlRestriction\(\) expects int, false given.#'
7 changes: 7 additions & 0 deletions tests/php/phpstan/phpstan-1.7.8.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
includes:
- %currentWorkingDirectory%/tests/php/phpstan/phpstan.neon

parameters:
ignoreErrors:
- '#Parameter \#1 \$share of static method ShopCore\:\:getContextListShopID\(\) expects string, false given.#'
- '#Parameter \#1 \$share of static method ShopCore\:\:addSqlRestriction\(\) expects int, false given.#'
5 changes: 5 additions & 0 deletions tests/php/phpstan/phpstan-latest.neon
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
includes:
- %currentWorkingDirectory%/tests/php/phpstan/phpstan.neon

parameters:
ignoreErrors:
- '#Parameter \#1 \$share of static method ShopCore\:\:getContextListShopID\(\) expects string, false given.#'
- '#Parameter \#1 \$share of static method ShopCore\:\:addSqlRestriction\(\) expects int, false given.#'
4 changes: 1 addition & 3 deletions tests/php/phpstan/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ parameters:
reportUnmatchedIgnoredErrors: false
level: 5
ignoreErrors:
- '~^Parameter #1 \$master of static method DbCore::getInstance\(\) expects bool, int given\.$~'
- '~^Parameter #1 \$share of static method ShopCore::getContextListShopID\(\) expects string, false given\.$~'
- '~^Parameter #1 \$share of static method ShopCore::addSqlRestriction\(\) expects int, false given\.$~'
- '#Unreachable statement \- code above always terminates\.#'

0 comments on commit e9f3a2e

Please sign in to comment.