Skip to content

Commit

Permalink
Merge pull request PrestaShop#21195 from matks/fix-stats-modules-not-…
Browse files Browse the repository at this point in the history
…displayed

Replaced SQL query to fetch modules hooked on stat hook by Hook function to have a singl Source of Truth
  • Loading branch information
Progi1984 authored Sep 29, 2020
2 parents 50e2355 + 0cbb3d5 commit 8b17212
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions controllers/admin/AdminStatsTabController.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,10 @@ public function checkModulesNames($a, $b)

protected function getModules()
{
$sql = 'SELECT h.`name` AS hook, m.`name`
FROM `' . _DB_PREFIX_ . 'module` m
LEFT JOIN `' . _DB_PREFIX_ . 'hook_module` hm ON hm.`id_module` = m.`id_module`
LEFT JOIN `' . _DB_PREFIX_ . 'hook` h ON hm.`id_hook` = h.`id_hook`
WHERE h.`name` = \'displayAdminStatsModules\'
AND m.`active` = 1
GROUP BY hm.id_module
ORDER BY hm.`position`';

return Db::getInstance()->executeS($sql);
return array_map(
function ($moduleArray) {return ['name' => $moduleArray['module']]; },
Hook::getHookModuleExecList('displayAdminStatsModules')
);
}

public function displayStats()
Expand Down

0 comments on commit 8b17212

Please sign in to comment.