From: Michael Date: Fri, 8 Apr 2022 06:04:50 +0000 (+0000) Subject: Use centralized function to fetch query results X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=69b7923df2beed71419bc38e61ca9755fad24b12;p=friendica.git Use centralized function to fetch query results --- diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 439f9b34ba..df1a25cd7d 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1461,7 +1461,7 @@ class Contact if ($pager->getStart() == 0) { $cdata = Contact::getPublicAndUserContactID($cid, local_user()); if (!empty($cdata['public'])) { - $pinned = DBA::selectToArray('collection-view', ['uri-id'], ['cid' => $cdata['public'], 'type' => Post\Collection::FEATURED]); + $pinned = Post\Collection::selectToArrayForContact($cdata['public'], Post\Collection::FEATURED, ['uri-id']); $items = array_merge($items, $pinned); } } diff --git a/src/Model/Post/Collection.php b/src/Model/Post/Collection.php index f7a1a996bb..476e9d3b33 100644 --- a/src/Model/Post/Collection.php +++ b/src/Model/Post/Collection.php @@ -58,4 +58,17 @@ class Collection DBA::delete('post-collection', ['uri-id' => $uri_id, 'type' => $type]); } + + /** + * Fetch collections for a given contact + * + * @param integer $cid + * @param [type] $type + * @param array $fields + * @return array + */ + public static function selectToArrayForContact(int $cid, int $type = self::FEATURED, array $fields = []) + { + return DBA::selectToArray('collection-view', $fields, ['cid' => $cid, 'type' => $type]); + } } diff --git a/src/Module/Profile/Status.php b/src/Module/Profile/Status.php index 23b78d959a..f3015692f3 100644 --- a/src/Module/Profile/Status.php +++ b/src/Module/Profile/Status.php @@ -209,7 +209,7 @@ class Status extends BaseProfile if ($pager->getStart() == 0 && !empty($profile['uid'])) { $pcid = Contact::getPublicIdByUserId($profile['uid']); - $pinned = DBA::selectToArray('collection-view', [], ['cid' => $pcid, 'type' => Post\Collection::FEATURED]); + $pinned = Post\Collection::selectToArrayForContact($pcid, Post\Collection::FEATURED); $items = array_merge($items, $pinned); } diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index d6bce87f4f..e5653a554f 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -999,7 +999,7 @@ class Processor return; } - $posts = DBA::selectToArray('collection-view', ['uri-id'], ['cid' => $pcid, 'type' => Post\Collection::FEATURED]); + $posts = Post\Collection::selectToArrayForContact($pcid, Post\Collection::FEATURED); if (!empty($posts)) { $old_featured = array_column($posts, 'uri-id'); }