Skip to content

Commit

Permalink
Merge pull request #183 from PrestaShop/dev
Browse files Browse the repository at this point in the history
Release 6.0.4
  • Loading branch information
M0rgan01 authored Sep 5, 2023
2 parents 2bf726d + 611a831 commit f4048a3
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 29 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@

Give more visibility to your content/static pages (CMS, external pages, or else), where you want and when you want, to make your visitors feel like shopping on your store.

## Compatibility

PrestaShop: `8.1.0` or later

## Multistore compatibility

This module is compatible with the multistore :heavy_check_mark: <br/>
It can be configured differently from one store to another.<br/>
It can be configured quickly in the same way on all stores thanks to the all shops context or the group of shops.<br/>
It can be activated on one store and deactivated on another

## How to test

Edit the existing linklist block and add custom contents
CRUD a new linklist block

## Building assets

If you need to change the javascript code you have to compile the assets, this operation is done
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>ps_linklist</name>
<displayName><![CDATA[Link List]]></displayName>
<version><![CDATA[6.0.3]]></version>
<version><![CDATA[6.0.4]]></version>
<description><![CDATA[Adds a block with several links.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[front_office_features]]></tab>
Expand Down
6 changes: 3 additions & 3 deletions ps_linklist.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function __construct()
{
$this->name = 'ps_linklist';
$this->author = 'PrestaShop';
$this->version = '6.0.3';
$this->version = '6.0.4';
$this->need_instance = 0;
$this->tab = 'front_office_features';

Expand Down Expand Up @@ -155,7 +155,7 @@ public function install()
/**
* @return bool
*
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Exception
*/
private function createTables()
{
Expand All @@ -174,7 +174,7 @@ private function createTables()
/**
* @return bool
*
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Exception
*/
private function installFixtures()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Form/ChoiceProvider/CategoryChoiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function getChoices()
$categories = $qb->execute()->fetchAll();
$choices = [];
foreach ($categories as $category) {
$choices[$category['name']] = $category['id_category'];
$choices[$category['id_category'] . ' ' . $category['name']] = $category['id_category'];
}

return $choices;
Expand Down
48 changes: 24 additions & 24 deletions src/Repository/LinkBlockRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
namespace PrestaShop\Module\LinkList\Repository;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Exception as DBALException;
use Doctrine\DBAL\Exception\ConnectionException;
use Doctrine\DBAL\Query\QueryBuilder;
use Doctrine\DBAL\Result;
use Hook;
use PrestaShop\Module\LinkList\Adapter\ObjectModelHandler;
use PrestaShop\PrestaShop\Adapter\Shop\Context;
Expand Down Expand Up @@ -238,8 +239,6 @@ public function delete($idLinkBlock): void

/**
* @return array
*
* @throws \Doctrine\DBAL\DBALException
*/
public function createTables()
{
Expand Down Expand Up @@ -271,11 +270,11 @@ public function createTables()
];

foreach ($queries as $query) {
$statement = $this->connection->executeQuery($query);

if ($statement instanceof Statement && 0 != (int) $statement->errorCode()) {
try {
$this->connection->executeQuery($query);
} catch (DBALException $e) {
$errors[] = [
'key' => json_encode($statement->errorInfo()),
'key' => json_encode($e->getMessage()),
'parameters' => [],
'domain' => 'Admin.Modules.Notification',
];
Expand All @@ -287,8 +286,6 @@ public function createTables()

/**
* @return array
*
* @throws \Doctrine\DBAL\DBALException
*/
public function installFixtures()
{
Expand Down Expand Up @@ -316,10 +313,12 @@ public function installFixtures()
}

foreach ($queries as $query) {
$statement = $this->connection->executeQuery($query);
if ($statement instanceof Statement && 0 != (int) $statement->errorCode()) {
$this->connection->executeQuery($query);
try {
$this->connection->executeQuery($query);
} catch (DBALException $e) {
$errors[] = [
'key' => json_encode($statement->errorInfo()),
'key' => json_encode($e->getMessage()),
'parameters' => [],
'domain' => 'Admin.Modules.Notification',
];
Expand All @@ -331,8 +330,6 @@ public function installFixtures()

/**
* @return array
*
* @throws \Doctrine\DBAL\DBALException
*/
public function dropTables()
{
Expand All @@ -344,10 +341,11 @@ public function dropTables()
];
foreach ($tableNames as $tableName) {
$sql = 'DROP TABLE IF EXISTS ' . $this->dbPrefix . $tableName;
$statement = $this->connection->executeQuery($sql);
if ($statement instanceof Statement && 0 != (int) $statement->errorCode()) {
try {
$this->connection->executeQuery($sql);
} catch (DBALException $e) {
$errors[] = [
'key' => json_encode($statement->errorInfo()),
'key' => json_encode($e->getMessage()),
'parameters' => [],
'domain' => 'Admin.Modules.Notification',
];
Expand Down Expand Up @@ -415,15 +413,16 @@ private function updateLanguages($linkBlockId, array $blockName, array $custom)
* @param QueryBuilder $qb
* @param string $errorPrefix
*
* @return Statement|int
* @return Result|int|string
*
* @throws DatabaseException
*/
private function executeQueryBuilder(QueryBuilder $qb, $errorPrefix = 'SQL error')
{
$statement = $qb->execute();
if ($statement instanceof Statement && !empty($statement->errorInfo())) {
throw new DatabaseException($errorPrefix . ': ' . var_export($statement->errorInfo(), true));
try {
$statement = $qb->execute();
} catch (DBALException $e) {
throw new DatabaseException($errorPrefix . ': ' . var_export($e->getMessage(), true));
}

return $statement;
Expand All @@ -447,7 +446,7 @@ private function getHookMaxPosition(int $idHook, int $idShop): int
->setParameter('idShop', $idShop)
;

$maxPosition = $qb->execute()->fetchColumn(0);
$maxPosition = $qb->execute()->fetch(\PDO::FETCH_COLUMN);

return null !== $maxPosition ? $maxPosition + 1 : 0;
}
Expand Down Expand Up @@ -500,8 +499,9 @@ public function updatePositions(int $shopId, array $positionsData = []): void

++$i;

$statement = $qb->execute();
if ($statement instanceof Statement && $statement->errorCode()) {
try {
$qb->execute();
} catch (DBALException $e) {
throw new DatabaseException('Could not update #%i');
}
}
Expand Down

0 comments on commit f4048a3

Please sign in to comment.