[-] FO: Fix infinite loop on overriding Module::getPaymentModules and executing hook on it #PSCFV-7760
This commit is contained in:
+1
-7
@@ -286,6 +286,7 @@ class HookCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
$sql->leftJoin('module_group', 'mg', 'mg.`id_module` = m.`id_module`');
|
$sql->leftJoin('module_group', 'mg', 'mg.`id_module` = m.`id_module`');
|
||||||
$sql->where('mg.`id_group` IN ('.implode(', ', $groups).')');
|
$sql->where('mg.`id_group` IN ('.implode(', ', $groups).')');
|
||||||
|
$sql->where(Module::getPaypalIgnore());
|
||||||
$sql->groupBy('hm.id_hook, hm.id_module');
|
$sql->groupBy('hm.id_hook, hm.id_module');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,16 +299,9 @@ class HookCore extends ObjectModel
|
|||||||
// Get all available payment module
|
// Get all available payment module
|
||||||
$payment_modules = array();
|
$payment_modules = array();
|
||||||
|
|
||||||
if (isset($context->shop->id))
|
|
||||||
foreach (Module::getPaymentModules() as $module)
|
|
||||||
$payment_modules[] = $module['name'];
|
|
||||||
|
|
||||||
if ($results)
|
if ($results)
|
||||||
foreach ($results as $row)
|
foreach ($results as $row)
|
||||||
{
|
{
|
||||||
if ($row['hook'] == 'displayPayment' && !in_array($row['module'], $payment_modules))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
$row['hook'] = strtolower($row['hook']);
|
$row['hook'] = strtolower($row['hook']);
|
||||||
if (!isset($list[$row['hook']]))
|
if (!isset($list[$row['hook']]))
|
||||||
$list[$row['hook']] = array();
|
$list[$row['hook']] = array();
|
||||||
|
|||||||
@@ -1308,6 +1308,14 @@ abstract class ModuleCore
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getPaypalIgnore()
|
||||||
|
{
|
||||||
|
$iso_code = Country::getIsoById((int)Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||||
|
$paypal_countries = array('ES', 'FR', 'PL', 'IT');
|
||||||
|
if (Context::getContext()->getMobileDevice() && Context::getContext()->shop->getTheme() == 'default' && in_array($iso_code, $paypal_countries))
|
||||||
|
return 'm.`name` = \'paypal\'';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of the payment module associated to the current customer
|
* Returns the list of the payment module associated to the current customer
|
||||||
* @see PaymentModule::getInstalledPaymentModules() if you don't care about the context
|
* @see PaymentModule::getInstalledPaymentModules() if you don't care about the context
|
||||||
@@ -1335,13 +1343,9 @@ abstract class ModuleCore
|
|||||||
if (Db::getInstance()->getValue('SELECT `id_hook` FROM `'._DB_PREFIX_.'hook` WHERE `name` = \'displayPayment\''))
|
if (Db::getInstance()->getValue('SELECT `id_hook` FROM `'._DB_PREFIX_.'hook` WHERE `name` = \'displayPayment\''))
|
||||||
$hookPayment = 'displayPayment';
|
$hookPayment = 'displayPayment';
|
||||||
|
|
||||||
$paypal_condition = '';
|
|
||||||
$iso_code = Country::getIsoById((int)Configuration::get('PS_COUNTRY_DEFAULT'));
|
|
||||||
$paypal_countries = array('ES', 'FR', 'PL', 'IT');
|
|
||||||
if (Context::getContext()->getMobileDevice() && Context::getContext()->shop->getTheme() == 'default' && in_array($iso_code, $paypal_countries))
|
|
||||||
$paypal_condition = ' AND m.`name` = \'paypal\'';
|
|
||||||
|
|
||||||
$list = Shop::getContextListShopID();
|
$list = Shop::getContextListShopID();
|
||||||
|
if ($paypal_condition = Module::getPaypalIgnore())
|
||||||
|
$paypal_condition = ' AND '.$paypal_condition;
|
||||||
|
|
||||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT DISTINCT m.`id_module`, h.`id_hook`, m.`name`, hm.`position`
|
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT DISTINCT m.`id_module`, h.`id_hook`, m.`name`, hm.`position`
|
||||||
FROM `'._DB_PREFIX_.'module` m
|
FROM `'._DB_PREFIX_.'module` m
|
||||||
|
|||||||
Reference in New Issue
Block a user