From 06ece5b72e5ced40d8f525eaffb95ab46463bd8d Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Sat, 8 Jan 2022 15:17:13 +0000 Subject: [PATCH] [COMPONENT][Collection] Only run queries if the criteria is not empty --- components/Collection/Collection.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/Collection/Collection.php b/components/Collection/Collection.php index 37ab4fe071..8c1cec9188 100644 --- a/components/Collection/Collection.php +++ b/components/Collection/Collection.php @@ -40,13 +40,13 @@ class Collection extends Component $actors = []; if (!\is_null($note_criteria)) { $note_qb->addCriteria($note_criteria); + $notes = $note_qb->getQuery()->execute(); } - $notes = $note_qb->getQuery()->execute(); if (!\is_null($actor_criteria)) { $actor_qb->addCriteria($actor_criteria); + $actors = $actor_qb->getQuery()->execute(); } - $actors = $actor_qb->getQuery()->execute(); // N.B.: Scope is only enforced at FeedController level return ['notes' => $notes ?? null, 'actors' => $actors ?? null];