From 44456e203260c8f9a4d5dd559b1c5c4ebf64c61b Mon Sep 17 00:00:00 2001 From: SharkyKZ Date: Mon, 26 Aug 2019 19:38:41 +0300 Subject: [PATCH] Less calls --- libraries/src/Helper/ContentHelper.php | 28 ++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/libraries/src/Helper/ContentHelper.php b/libraries/src/Helper/ContentHelper.php index 7c69856bd584a..8a11123651dec 100644 --- a/libraries/src/Helper/ContentHelper.php +++ b/libraries/src/Helper/ContentHelper.php @@ -119,11 +119,19 @@ public static function countRelations(&$items, $config) if ($usesWorkflows) { - $query->from($db->quoteName('#__workflow_stages', 's')) - ->from($db->quoteName('#__workflow_associations', 'a')) - ->where($db->quoteName('s.id') . ' = ' . $db->quoteName('a.stage_id')) - ->where($db->quoteName('a.extension') . ' = :component') - ->where($db->quoteName('a.item_id') . ' = ' . $db->quoteName('c.id')) + $query->from( + [ + $db->quoteName('#__workflow_stages', 's'), + $db->quoteName('#__workflow_associations', 'a'), + ] + ) + ->where( + [ + $db->quoteName('s.id') . ' = ' . $db->quoteName('a.stage_id'), + $db->quoteName('a.extension') . ' = :component', + $db->quoteName('a.item_id') . ' = ' . $db->quoteName('c.id'), + ] + ) ->bind(':component', $config->workflows_component); } @@ -132,9 +140,13 @@ public static function countRelations(&$items, $config) * NOTE: 'state IN', allows counting specific states / conditions only, also prevents warnings with custom states / conditions, do not remove */ $query - ->select($db->quoteName($recid_col, 'catid')) - ->select($db->quoteName($state_col, 'state')) - ->select('COUNT(*) AS ' . $db->quoteName('count')) + ->select( + [ + $db->quoteName($recid_col, 'catid'), + $db->quoteName($state_col, 'state'), + 'COUNT(*) AS ' . $db->quoteName('count'), + ] + ) ->whereIn($db->quoteName($recid_col), array_keys($records)) ->whereIn($db->quoteName($state_col), array_keys($counter_names)) ->group($db->quoteName([$recid_col, $state_col]));