From 5d9083c3691b15655c403e0bffde039702b6c61e Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 10 Jun 2018 07:26:37 +0000 Subject: [PATCH] Bugfix in notifications / network and display are using the new functions now --- include/conversation.php | 19 ++++++++++--------- include/enotify.php | 1 + mod/display.php | 10 +++++----- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index e63488df2d..527f38e2aa 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -15,6 +15,7 @@ use Friendica\Core\System; use Friendica\Database\DBM; use Friendica\Model\Contact; use Friendica\Model\Profile; +use Friendica\Model\Item; use Friendica\Object\Post; use Friendica\Object\Thread; use Friendica\Util\DateTimeFormat; @@ -865,21 +866,21 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order = function conversation_add_children($parents, $block_authors, $order, $uid) { $max_comments = Config::get('system', 'max_comments', 100); + $params = ['order' => ['uid', 'commented' => true]]; + if ($max_comments > 0) { - $limit = ' LIMIT '.intval($max_comments + 1); - } else { - $limit = ''; + $params['limit'] = $max_comments; } $items = []; - $block_sql = $block_authors ? "AND NOT `author`.`hidden` AND NOT `author`.`blocked`" : ""; - foreach ($parents AS $parent) { - $thread_items = dba::p(item_query(local_user())."AND `item`.`parent-uri` = ? - AND `item`.`uid` IN (0, ?) $block_sql - ORDER BY `item`.`uid` ASC, `item`.`commented` DESC" . $limit, - $parent['uri'], local_user()); + $condition = ["`item`.`parent-uri` = ? AND `item`.`uid` IN (0, ?) ", + $parent['uri'], local_user()]; + if ($block_authors) { + $condition[0] .= "AND NOT `author`.`hidden`"; + } + $thread_items = Item::select(local_user(), [], $condition, $params); $comments = dba::inArray($thread_items); diff --git a/include/enotify.php b/include/enotify.php index d98465c6ec..7eb2c80ebc 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -11,6 +11,7 @@ use Friendica\Core\System; use Friendica\Database\DBM; use Friendica\Util\DateTimeFormat; use Friendica\Util\Emailer; +use Friendica\Model\Item; /** * @brief Creates a notification entry and possibly sends a mail diff --git a/mod/display.php b/mod/display.php index 6380e6f6ca..816af820a1 100644 --- a/mod/display.php +++ b/mod/display.php @@ -14,6 +14,7 @@ use Friendica\Core\System; use Friendica\Database\DBM; use Friendica\Model\Contact; use Friendica\Model\Group; +use Friendica\Model\Item; use Friendica\Model\Profile; use Friendica\Protocol\DFRN; @@ -345,11 +346,10 @@ function display_content(App $a, $update = false, $update_uid = 0) { return ''; } - $r = dba::p(item_query(local_user())."AND `item`.`parent-uri` = (SELECT `parent-uri` FROM `item` WHERE `id` = ?) - AND `item`.`uid` IN (0, ?) $sql_extra - ORDER BY `item`.`uid` ASC, `parent` DESC, `gravity` ASC, `id` ASC", - $item_id, local_user() - ); + $condition = ["`item`.`parent-uri` = (SELECT `parent-uri` FROM `item` WHERE `id` = ?) + AND `item`.`uid` IN (0, ?) " . $sql_extra, $item_id, local_user()]; + $params = ['order' => ['uid', 'parent' => true, 'gravity', 'id']]; + $r = Item::select(local_user(), [], $condition, $params); if (!DBM::is_result($r)) { notice(L10n::t('Item not found.') . EOL);