Skip to content

Commit

Permalink
unhook modules before deleting hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
atomiix committed Jan 8, 2021
1 parent 00e57eb commit 874dad8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 16 deletions.
42 changes: 42 additions & 0 deletions install-dev/upgrade/php/delete_hook.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?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 Open Software License (OSL 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/OSL-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 [email protected] 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 <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

function delete_hook($hook)
{
$modules = Hook::getHookModuleExecList($hook);
if (is_array($modules)) {
foreach ($modules as $module) {
$moduleInstance = Module::getInstanceByName($module['module']);
if ($moduleInstance instanceof Module) {
Hook::unregisterHook($moduleInstance, $hook);
}
}
}

return (bool) Db::getInstance()->execute(
'DELETE FROM `' . _DB_PREFIX_ . 'hook` WHERE `name` = "' . pSQL($hook) . '"'
);
}
30 changes: 14 additions & 16 deletions install-dev/upgrade/sql/1.7.0.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ ALTER TABLE `PREFIX_product_lang` ADD `social_sharing_description` VARCHAR( 25
ALTER TABLE `PREFIX_hook` DROP `live_edit`;

/* Remove comparator feature */
DELETE FROM `PREFIX_hook_alias` WHERE `name` = 'displayProductComparison';
DELETE FROM `PREFIX_hook` WHERE `name` = 'displayProductComparison';
DELETE FROM `PREFIX_meta` WHERE `page` = 'products-comparison';
DROP TABLE IF EXISTS `PREFIX_compare`;
DROP TABLE IF EXISTS `PREFIX_compare_product`;
Expand Down Expand Up @@ -156,19 +154,18 @@ INSERT INTO `PREFIX_hook` (`name`, `title`, `description`, `position`) VALUES
('displayAfterBodyOpeningTag', 'Very top of pages', 'Use this hook for advertisement or modals you want to load first.', '1'),
('displayBeforeBodyClosingTag', 'Very bottom of pages', 'Use this hook for your modals or any content you want to load at the very end.', '1');


DELETE FROM `PREFIX_hook` WHERE `name` IN (
'displayProductTab',
'displayProductTabContent',
'displayBeforePayment',
'actionBeforeAuthentication',
'actionOrderDetail',
'actionProductListOverride',
'actionSearch',
'displayCustomerIdentityForm',
'displayHomeTab',
'displayHomeTabContent',
'displayPayment');
/* PHP:delete_hook(displayProductTab); */;
/* PHP:delete_hook(displayProductTabContent); */;
/* PHP:delete_hook(displayBeforePayment); */;
/* PHP:delete_hook(actionBeforeAuthentication); */;
/* PHP:delete_hook(actionOrderDetail); */;
/* PHP:delete_hook(actionProductListOverride); */;
/* PHP:delete_hook(actionSearch); */;
/* PHP:delete_hook(displayCustomerIdentityForm); */;
/* PHP:delete_hook(displayHomeTab); */;
/* PHP:delete_hook(displayHomeTabContent); */;
/* PHP:delete_hook(displayPayment); */;
/* PHP:delete_hook(displayProductComparison); */;

DELETE FROM `PREFIX_hook_alias` WHERE `name` IN (
'beforeAuthentication',
Expand All @@ -178,7 +175,8 @@ DELETE FROM `PREFIX_hook_alias` WHERE `name` IN (
'orderDetail',
'payment',
'productListAssign',
'search');
'search',
'displayProductComparison');

DELETE FROM `PREFIX_configuration` WHERE `name` IN (
'_MEDIA_SERVER_2_',
Expand Down

0 comments on commit 874dad8

Please sign in to comment.