Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 0 additions & 75 deletions install.sql

This file was deleted.

61 changes: 35 additions & 26 deletions productcomments.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@

class ProductComments extends Module implements WidgetInterface
{
const INSTALL_SQL_FILE = 'install.sql';

private $_html = '';

private $_productCommentsCriterionTypes = [];
Expand All @@ -47,7 +45,7 @@ public function __construct()
{
$this->name = 'productcomments';
$this->tab = 'front_office_features';
$this->version = '6.0.3';
$this->version = '6.0.4';
$this->author = 'PrestaShop';
$this->need_instance = 0;
$this->bootstrap = true;
Expand All @@ -70,19 +68,8 @@ public function install($keep = true)
}

if ($keep) {
if (!file_exists(dirname(__FILE__) . '/' . self::INSTALL_SQL_FILE)) {
return false;
} elseif (!$sql = file_get_contents(dirname(__FILE__) . '/' . self::INSTALL_SQL_FILE)) {
return false;
}
$sql = str_replace(['PREFIX_', 'ENGINE_TYPE'], [_DB_PREFIX_, _MYSQL_ENGINE_], $sql);
$sql = preg_split("/;\s*[\r\n]+/", trim($sql));

foreach ($sql as $query) {
if (!Db::getInstance()->execute(trim($query))) {
return false;
}
}
$entitySchemaManager = $this->getEntitySchemaManager();
$entitySchemaManager->createMultiple($this->getEntitiesList());
}

if (
Expand Down Expand Up @@ -149,16 +136,21 @@ public function reset()

public function deleteTables()
{
return Db::getInstance()->execute('
DROP TABLE IF EXISTS
`' . _DB_PREFIX_ . 'product_comment`,
`' . _DB_PREFIX_ . 'product_comment_criterion`,
`' . _DB_PREFIX_ . 'product_comment_criterion_product`,
`' . _DB_PREFIX_ . 'product_comment_criterion_lang`,
`' . _DB_PREFIX_ . 'product_comment_criterion_category`,
`' . _DB_PREFIX_ . 'product_comment_grade`,
`' . _DB_PREFIX_ . 'product_comment_usefulness`,
`' . _DB_PREFIX_ . 'product_comment_report`');
$entitySchemaManager = $this->getEntitySchemaManager();

return $entitySchemaManager->dropMultiple($this->getEntitiesList());
}

/**
* Update entities tables schema
*
* @return bool
*/
public function updateTablesSchema(): bool
{
$entitySchemaManager = $this->getEntitySchemaManager();

return $entitySchemaManager->updateMultiple($this->getEntitiesList());
}

public function getCacheId($id_product = null)
Expand Down Expand Up @@ -1104,4 +1096,21 @@ public function hookRegisterGDPRConsent()
at module installation.
*/
}

/**
* Return array with module Symfony entities list
*
* @return array
*/
protected function getEntitiesList(): array
{
return [
PrestaShop\Module\ProductComment\Entity\ProductComment::class,
PrestaShop\Module\ProductComment\Entity\ProductCommentCriterion::class,
PrestaShop\Module\ProductComment\Entity\ProductCommentCriterionLang::class,
PrestaShop\Module\ProductComment\Entity\ProductCommentGrade::class,
PrestaShop\Module\ProductComment\Entity\ProductCommentReport::class,
PrestaShop\Module\ProductComment\Entity\ProductCommentUsefulness::class,
];
}
}
33 changes: 33 additions & 0 deletions upgrade/install-6.0.4.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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 license@prestashop.com 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 <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}

function upgrade_module_6_0_4($module)
{
return $module->updateTablesSchema();
}