From 65c8f337549e502ed0d720dee33858fee14d3f76 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 16 Jan 2021 04:11:28 +0000 Subject: [PATCH 1/9] Post class introduced in "mod" and "include" --- include/api.php | 23 ++++++++++++----------- include/conversation.php | 11 ++++++----- include/enotify.php | 5 +++-- mod/display.php | 13 +++++++------ mod/events.php | 3 ++- mod/follow.php | 3 ++- mod/item.php | 12 ++++++------ mod/photos.php | 5 +++-- mod/share.php | 3 ++- mod/tagger.php | 3 ++- mod/tagrm.php | 5 +++-- mod/update_contact.php | 4 ++-- update.php | 3 ++- 13 files changed, 52 insertions(+), 41 deletions(-) diff --git a/include/api.php b/include/api.php index 5131c9574..26a377821 100644 --- a/include/api.php +++ b/include/api.php @@ -41,6 +41,7 @@ use Friendica\Model\Item; use Friendica\Model\Mail; use Friendica\Model\Notify; use Friendica\Model\Photo; +use Friendica\Model\Post; use Friendica\Model\User; use Friendica\Model\UserItem; use Friendica\Model\Verb; @@ -1365,7 +1366,7 @@ function api_get_last_status($ownerId, $uid) */ function api_get_item(array $condition) { - $item = Item::selectFirst(Item::DISPLAY_FIELDLIST, $condition, ['order' => ['id' => true]]); + $item = Post::selectFirst(Item::DISPLAY_FIELDLIST, $condition, ['order' => ['id' => true]]); return $item; } @@ -1673,7 +1674,7 @@ function api_statuses_home_timeline($type) } if (!empty($idarray)) { - $unseen = Item::exists(['unseen' => true, 'id' => $idarray]); + $unseen = Post::exists(['unseen' => true, 'id' => $idarray]); if ($unseen) { Item::update(['unseen' => false], ['unseen' => true, 'id' => $idarray]); } @@ -1880,12 +1881,12 @@ function api_statuses_show($type) $conversation = !empty($_REQUEST['conversation']); // try to fetch the item for the local user - or the public item, if there is no local one - $uri_item = Item::selectFirst(['uri'], ['id' => $id]); + $uri_item = Post::selectFirst(['uri'], ['id' => $id]); if (!DBA::isResult($uri_item)) { throw new BadRequestException("There is no status with this id."); } - $item = Item::selectFirst(['id'], ['uri' => $uri_item['uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]); + $item = Post::selectFirst(['id'], ['uri' => $uri_item['uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]); if (!DBA::isResult($item)) { throw new BadRequestException("There is no status with this id."); } @@ -1963,12 +1964,12 @@ function api_conversation_show($type) Logger::info(API_LOG_PREFIX . '{subaction}', ['module' => 'api', 'action' => 'conversation', 'subaction' => 'show', 'id' => $id]); // try to fetch the item for the local user - or the public item, if there is no local one - $item = Item::selectFirst(['parent-uri'], ['id' => $id]); + $item = Post::selectFirst(['parent-uri'], ['id' => $id]); if (!DBA::isResult($item)) { throw new BadRequestException("There is no status with this id."); } - $parent = Item::selectFirst(['id'], ['uri' => $item['parent-uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]); + $parent = Post::selectFirst(['id'], ['uri' => $item['parent-uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]); if (!DBA::isResult($parent)) { throw new BadRequestException("There is no status with this id."); } @@ -2040,7 +2041,7 @@ function api_statuses_repeat($type) Logger::log('API: api_statuses_repeat: '.$id); $fields = ['uri-id', 'network', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink']; - $item = Item::selectFirst($fields, ['id' => $id, 'private' => [Item::PUBLIC, Item::UNLISTED]]); + $item = Post::selectFirst($fields, ['id' => $id, 'private' => [Item::PUBLIC, Item::UNLISTED]]); if (DBA::isResult($item) && $item['body'] != "") { if (in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::TWITTER])) { @@ -4879,7 +4880,7 @@ function prepare_photo_data($type, $scale, $photo_id) // retrieve item element for getting activities (like, dislike etc.) related to photo $condition = ['uid' => api_user(), 'resource-id' => $photo_id, 'type' => 'photo']; - $item = Item::selectFirst(['id', 'uid', 'uri', 'parent', 'allow_cid', 'deny_cid', 'allow_gid', 'deny_gid'], $condition); + $item = Post::selectFirst(['id', 'uid', 'uri', 'parent', 'allow_cid', 'deny_cid', 'allow_gid', 'deny_gid'], $condition); if (!DBA::isResult($item)) { throw new NotFoundException('Photo-related item not found.'); } @@ -5075,7 +5076,7 @@ function api_share_as_retweet(&$item) } if (!empty($condition)) { - $original_item = Item::selectFirst([], $condition); + $original_item = Post::selectFirst([], $condition); if (DBA::isResult($original_item)) { $reshared_item = array_merge($reshared_item, $original_item); } @@ -5102,7 +5103,7 @@ function api_in_reply_to($item) $in_reply_to['screen_name'] = null; if (($item['thr-parent'] != $item['uri']) && ($item['gravity'] != GRAVITY_PARENT)) { - $parent = Item::selectFirst(['id'], ['uid' => $item['uid'], 'uri' => $item['thr-parent']]); + $parent = Post::selectFirst(['id'], ['uid' => $item['uid'], 'uri' => $item['thr-parent']]); if (DBA::isResult($parent)) { $in_reply_to['status_id'] = intval($parent['id']); } else { @@ -5112,7 +5113,7 @@ function api_in_reply_to($item) $in_reply_to['status_id_str'] = (string) intval($in_reply_to['status_id']); $fields = ['author-nick', 'author-name', 'author-id', 'author-link']; - $parent = Item::selectFirst($fields, ['id' => $in_reply_to['status_id']]); + $parent = Post::selectFirst($fields, ['id' => $in_reply_to['status_id']]); if (DBA::isResult($parent)) { $in_reply_to['screen_name'] = (($parent['author-nick']) ? $parent['author-nick'] : $parent['author-name']); diff --git a/include/conversation.php b/include/conversation.php index f681155a4..d269bc72a 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -33,10 +33,11 @@ use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Item; +use Friendica\Model\Post; use Friendica\Model\Profile; use Friendica\Model\Tag; use Friendica\Model\Verb; -use Friendica\Object\Post; +use Friendica\Object\Post as ObjectPost; use Friendica\Object\Thread; use Friendica\Protocol\Activity; use Friendica\Util\Crypto; @@ -201,7 +202,7 @@ function localize_item(&$item) if ($activity->match($item['verb'], Activity::TAG)) { $fields = ['author-id', 'author-link', 'author-name', 'author-network', 'verb', 'object-type', 'resource-id', 'body', 'plink']; - $obj = Item::selectFirst($fields, ['uri' => $item['parent-uri']]); + $obj = Post::selectFirst($fields, ['uri' => $item['parent-uri']]); if (!DBA::isResult($obj)) { return; } @@ -677,7 +678,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o $item['pagedrop'] = $page_dropping; if ($item['gravity'] == GRAVITY_PARENT) { - $item_object = new Post($item); + $item_object = new ObjectPost($item); $conv->addParent($item_object); } } @@ -871,7 +872,7 @@ function conversation_fetch_items(array $parent, array $items, array $condition, $condition[0] .= " AND NOT `author`.`hidden`"; } - $thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity', 'post-type']), $condition, $params); + $thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['pinned', 'contact-uid', 'gravity', 'post-type']), $condition, $params); $comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false, $activity); @@ -1041,7 +1042,7 @@ function builtin_activity_puller(array $activity, array &$conv_responses) } // Skip when the causer of the parent is the same than the author of the announce - if (($verb == Activity::ANNOUNCE) && Item::exists(['uri' => $activity['thr-parent'], + if (($verb == Activity::ANNOUNCE) && Post::exists(['uri' => $activity['thr-parent'], 'uid' => $activity['uid'], 'causer-id' => $activity['author-id'], 'gravity' => GRAVITY_PARENT])) { continue; } diff --git a/include/enotify.php b/include/enotify.php index f09cbf29a..fc19d400f 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -30,6 +30,7 @@ use Friendica\Model\Contact; use Friendica\Model\Item; use Friendica\Model\ItemContent; use Friendica\Model\Notify; +use Friendica\Model\Post; use Friendica\Model\User; use Friendica\Model\UserItem; use Friendica\Protocol\Activity; @@ -518,7 +519,7 @@ function notification($params) Logger::log('sending notification email'); if (isset($params['parent']) && (intval($params['parent']) != 0)) { - $parent = Item::selectFirst(['guid'], ['id' => $params['parent']]); + $parent = Post::selectFirst(['guid'], ['id' => $params['parent']]); $message_id = "<" . $parent['guid'] . "@" . gethostname() . ">"; // Is this the first email notification for this parent item and user? @@ -650,7 +651,7 @@ function check_item_notification($itemid, $uid, $notification_type) { // Special treatment for posts that had been shared via "announce" if ($item['gravity'] == GRAVITY_ACTIVITY) { - $parent_item = Item::selectFirst($fields, ['uri-id' => $item['thr-parent-id'], 'uid' => [$uid, 0]]); + $parent_item = Post::selectFirst($fields, ['uri-id' => $item['thr-parent-id'], 'uid' => [$uid, 0]]); if (DBA::isResult($parent_item)) { // Don't notify on own entries if (User::getIdForURL($parent_item['author-link']) == $uid) { diff --git a/mod/display.php b/mod/display.php index 81dce59e2..07289e013 100644 --- a/mod/display.php +++ b/mod/display.php @@ -32,6 +32,7 @@ use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Item; +use Friendica\Model\Post; use Friendica\Model\Profile; use Friendica\Module\Objects; use Friendica\Network\HTTPException; @@ -70,7 +71,7 @@ function display_init(App $a) // Is this item private but could be visible to the remove visitor? if (!DBA::isResult($item) && remote_user()) { - $item = Item::selectFirst($fields, ['guid' => $a->argv[1], 'private' => Item::PRIVATE, 'origin' => true]); + $item = Post::selectFirst($fields, ['guid' => $a->argv[1], 'private' => Item::PRIVATE, 'origin' => true]); if (DBA::isResult($item)) { if (!Contact::isFollower(remote_user(), $item['uid'])) { $item = null; @@ -187,7 +188,7 @@ function display_content(App $a, $update = false, $update_uid = 0) if ($update) { $item_id = $_REQUEST['item_id']; - $item = Item::selectFirst(['uid', 'parent', 'parent-uri', 'parent-uri-id'], ['id' => $item_id]); + $item = Post::selectFirst(['uid', 'parent', 'parent-uri', 'parent-uri-id'], ['id' => $item_id]); if ($item['uid'] != 0) { $a->profile = ['uid' => intval($item['uid'])]; } else { @@ -214,7 +215,7 @@ function display_content(App $a, $update = false, $update_uid = 0) } if (($item_parent == 0) && remote_user()) { - $item = Item::selectFirst($fields, ['guid' => $a->argv[1], 'private' => Item::PRIVATE, 'origin' => true]); + $item = Post::selectFirst($fields, ['guid' => $a->argv[1], 'private' => Item::PRIVATE, 'origin' => true]); if (DBA::isResult($item) && Contact::isFollower(remote_user(), $item['uid'])) { $item_id = $item['id']; $item_parent = $item['parent']; @@ -243,7 +244,7 @@ function display_content(App $a, $update = false, $update_uid = 0) } // We are displaying an "alternate" link if that post was public. See issue 2864 - $is_public = Item::exists(['id' => $item_id, 'private' => [Item::PUBLIC, Item::UNLISTED]]); + $is_public = Post::exists(['id' => $item_id, 'private' => [Item::PUBLIC, Item::UNLISTED]]); if ($is_public) { // For the atom feed the nickname doesn't matter at all, we only need the item id. $alternate = DI::baseUrl().'/display/feed-item/'.$item_id.'.atom'; @@ -262,7 +263,7 @@ function display_content(App $a, $update = false, $update_uid = 0) $parent = null; if (!empty($item_parent_uri)) { - $parent = Item::selectFirst(['uid'], ['uri' => $item_parent_uri, 'wall' => true]); + $parent = Post::selectFirst(['uid'], ['uri' => $item_parent_uri, 'wall' => true]); } if (DBA::isResult($parent)) { @@ -305,7 +306,7 @@ function display_content(App $a, $update = false, $update_uid = 0) if (local_user() && (local_user() == $a->profile['uid'])) { $condition = ['parent-uri' => $item_parent_uri, 'uid' => local_user(), 'unseen' => true]; - $unseen = Item::exists($condition); + $unseen = Post::exists($condition); } else { $unseen = false; } diff --git a/mod/events.php b/mod/events.php index 04a88e98b..291535df3 100644 --- a/mod/events.php +++ b/mod/events.php @@ -34,6 +34,7 @@ use Friendica\DI; use Friendica\Model\Conversation; use Friendica\Model\Event; use Friendica\Model\Item; +use Friendica\Model\Post; use Friendica\Model\User; use Friendica\Module\BaseProfile; use Friendica\Module\Security\Login; @@ -589,7 +590,7 @@ function events_content(App $a) Item::deleteForUser(['id' => $ev[0]['itemid']], local_user()); } - if (Item::exists(['id' => $ev[0]['itemid']])) { + if (Post::exists(['id' => $ev[0]['itemid']])) { notice(DI::l10n()->t('Failed to remove event')); } diff --git a/mod/follow.php b/mod/follow.php index b01395874..a1b9dba22 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -28,6 +28,7 @@ use Friendica\Model\Profile; use Friendica\Model\Item; use Friendica\Network\Probe; use Friendica\Database\DBA; +use Friendica\Model\Post; use Friendica\Model\User; use Friendica\Util\Strings; @@ -213,7 +214,7 @@ function follow_remote_item($url) } if (!empty($item_id)) { - $item = Item::selectFirst(['guid'], ['id' => $item_id]); + $item = Post::selectFirst(['guid'], ['id' => $item_id]); if (DBA::isResult($item)) { DI::baseUrl()->redirect('display/' . $item['guid']); } diff --git a/mod/item.php b/mod/item.php index 1ce1517a7..c00faf5dc 100644 --- a/mod/item.php +++ b/mod/item.php @@ -114,9 +114,9 @@ function item_post(App $a) { if ($parent_item_id || $thr_parent_uri) { if ($parent_item_id) { - $parent_item = Item::selectFirst([], ['id' => $parent_item_id]); + $parent_item = Post::selectFirst([], ['id' => $parent_item_id]); } elseif ($thr_parent_uri) { - $parent_item = Item::selectFirst([], ['uri' => $thr_parent_uri, 'uid' => $profile_uid]); + $parent_item = Post::selectFirst([], ['uri' => $thr_parent_uri, 'uid' => $profile_uid]); } // if this isn't the top-level parent of the conversation, find it @@ -126,7 +126,7 @@ function item_post(App $a) { $toplevel_item = $parent_item; if ($parent_item['gravity'] != GRAVITY_PARENT) { - $toplevel_item = Item::selectFirst([], ['id' => $toplevel_item['parent']]); + $toplevel_item = Post::selectFirst([], ['id' => $toplevel_item['parent']]); } } @@ -144,7 +144,7 @@ function item_post(App $a) { $stored = Item::storeForUserByUriId($toplevel_item['uri-id'], local_user()); Logger::info('Public item stored for user', ['uri-id' => $toplevel_item['uri-id'], 'uid' => $uid, 'stored' => $stored]); if ($stored) { - $toplevel_item = Item::selectFirst([], ['id' => $stored]); + $toplevel_item = Post::selectFirst([], ['id' => $stored]); } } @@ -193,7 +193,7 @@ function item_post(App $a) { // is this an edited post? if ($post_id > 0) { - $orig_post = Item::selectFirst(Item::ITEM_FIELDLIST, ['id' => $post_id]); + $orig_post = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $post_id]); } $user = User::getById($profile_uid, ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid']); @@ -728,7 +728,7 @@ function item_post(App $a) { throw new HTTPException\InternalServerErrorException(DI::l10n()->t('Item wasn\'t stored.')); } - $datarray = Item::selectFirst(Item::ITEM_FIELDLIST, ['id' => $post_id]); + $datarray = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $post_id]); if (!DBA::isResult($datarray)) { Logger::error('Item couldn\'t be fetched.', ['post_id' => $post_id]); diff --git a/mod/photos.php b/mod/photos.php index ca5b66abe..817e9fc53 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -36,6 +36,7 @@ use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Item; use Friendica\Model\Photo; +use Friendica\Model\Post; use Friendica\Model\Profile; use Friendica\Model\Tag; use Friendica\Model\User; @@ -427,7 +428,7 @@ function photos_post(App $a) } if ($item_id) { - $item = Item::selectFirst(['tag', 'inform', 'uri-id'], ['id' => $item_id, 'uid' => $page_owner_uid]); + $item = Post::selectFirst(['tag', 'inform', 'uri-id'], ['id' => $item_id, 'uid' => $page_owner_uid]); if (DBA::isResult($item)) { $old_inform = $item['inform']; @@ -1270,7 +1271,7 @@ function photos_content(App $a) ); if (DBA::isResult($linked_items)) { // This is a workaround to not being forced to rewrite the while $sql_extra handling - $link_item = Item::selectFirst([], ['id' => $linked_items[0]['id']]); + $link_item = Post::selectFirst([], ['id' => $linked_items[0]['id']]); } if (!empty($link_item['parent']) && !empty($link_item['uid'])) { diff --git a/mod/share.php b/mod/share.php index a8ac3bd8b..b606c1a66 100644 --- a/mod/share.php +++ b/mod/share.php @@ -23,6 +23,7 @@ use Friendica\App; use Friendica\Content\Text\BBCode; use Friendica\Database\DBA; use Friendica\Model\Item; +use Friendica\Model\Post; function share_init(App $a) { $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); @@ -33,7 +34,7 @@ function share_init(App $a) { $fields = ['private', 'body', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'title']; - $item = Item::selectFirst($fields, ['id' => $post_id]); + $item = Post::selectFirst($fields, ['id' => $post_id]); if (!DBA::isResult($item) || $item['private'] == Item::PRIVATE) { exit(); diff --git a/mod/tagger.php b/mod/tagger.php index 63e7f2ca8..38575a215 100644 --- a/mod/tagger.php +++ b/mod/tagger.php @@ -28,6 +28,7 @@ use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Item; +use Friendica\Model\Post; use Friendica\Model\Tag; use Friendica\Protocol\Activity; use Friendica\Util\Strings; @@ -53,7 +54,7 @@ function tagger_content(App $a) { Logger::log('tagger: tag ' . $term . ' item ' . $item_id); - $item = Item::selectFirst([], ['id' => $item_id]); + $item = Post::selectFirst([], ['id' => $item_id]); if (!$item_id || !DBA::isResult($item)) { Logger::log('tagger: no item ' . $item_id); diff --git a/mod/tagrm.php b/mod/tagrm.php index 179276663..f376573fe 100644 --- a/mod/tagrm.php +++ b/mod/tagrm.php @@ -24,6 +24,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Item; +use Friendica\Model\Post; use Friendica\Model\Tag; use Friendica\Util\Strings; @@ -62,7 +63,7 @@ function update_tags($item_id, $tags) return; } - $item = Item::selectFirst(['uri-id'], ['id' => $item_id, 'uid' => local_user()]); + $item = Post::selectFirst(['uri-id'], ['id' => $item_id, 'uid' => local_user()]); if (!DBA::isResult($item)) { return; } @@ -96,7 +97,7 @@ function tagrm_content(App $a) // NOTREACHED } - $item = Item::selectFirst(['uri-id'], ['id' => $item_id, 'uid' => local_user()]); + $item = Post::selectFirst(['uri-id'], ['id' => $item_id, 'uid' => local_user()]); if (!DBA::isResult($item)) { DI::baseUrl()->redirect($_SESSION['photo_return']); } diff --git a/mod/update_contact.php b/mod/update_contact.php index 9681e7c17..44bb4a36a 100644 --- a/mod/update_contact.php +++ b/mod/update_contact.php @@ -24,14 +24,14 @@ use Friendica\App; use Friendica\Core\System; use Friendica\DI; -use Friendica\Model\Item; +use Friendica\Model\Post; use Friendica\Module\Contact; function update_contact_content(App $a) { if (!empty($a->argv[1]) && (!empty($_GET['force']) || !DI::pConfig()->get(local_user(), 'system', 'no_auto_update'))) { if (!empty($_GET['item'])) { - $item = Item::selectFirst(['parent'], ['id' => $_GET['item']]); + $item = Post::selectFirst(['parent'], ['id' => $_GET['item']]); $parentid = $item['parent'] ?? 0; } else { $parentid = 0; diff --git a/update.php b/update.php index b5d178489..d8a281737 100644 --- a/update.php +++ b/update.php @@ -52,6 +52,7 @@ use Friendica\Model\Contact; use Friendica\Model\Item; use Friendica\Model\Notify; use Friendica\Model\Photo; +use Friendica\Model\Post; use Friendica\Model\User; use Friendica\Model\Storage; use Friendica\Util\DateTimeFormat; @@ -336,7 +337,7 @@ function update_1309() continue; } - $item = Item::selectFirst(['id', 'gravity'], ['uid' => $contact['uid'], 'guid' => $entry['guid']]); + $item = Post::selectFirst(['id', 'gravity'], ['uid' => $contact['uid'], 'guid' => $entry['guid']]); if (!DBA::isResult($item)) { continue; } From e83e3956d84d89738811ff3fda2b4b362562da53 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 16 Jan 2021 04:45:05 +0000 Subject: [PATCH 2/9] Make the tests happy --- src/Model/Item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index 60976363a..60477ab16 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -82,7 +82,7 @@ class Item 'owner-id', 'owner-link', 'owner-name', 'owner-avatar', 'owner-network', 'causer-id', 'causer-link', 'causer-name', 'causer-avatar', 'causer-contact-type', 'contact-id', 'contact-uid', 'contact-link', 'contact-name', 'contact-avatar', - 'writable', 'self', 'cid', 'alias', 'pinned', + 'writable', 'self', 'cid', 'alias', 'event-id', 'event-created', 'event-edited', 'event-start', 'event-finish', 'event-summary', 'event-desc', 'event-location', 'event-type', 'event-nofinish', 'event-adjust', 'event-ignore', 'event-id', From 1b39e056fe360d9b49f192dd033ad8cb36ba1587 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 16 Jan 2021 05:10:43 +0000 Subject: [PATCH 3/9] Check if the tests are running now --- include/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/api.php b/include/api.php index 26a377821..b649d2248 100644 --- a/include/api.php +++ b/include/api.php @@ -2041,7 +2041,7 @@ function api_statuses_repeat($type) Logger::log('API: api_statuses_repeat: '.$id); $fields = ['uri-id', 'network', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink']; - $item = Post::selectFirst($fields, ['id' => $id, 'private' => [Item::PUBLIC, Item::UNLISTED]]); + $item = Item::selectFirst($fields, ['id' => $id, 'private' => [Item::PUBLIC, Item::UNLISTED]]); if (DBA::isResult($item) && $item['body'] != "") { if (in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::TWITTER])) { From 352f1fcae231a1b0a21a0f7926efe0061592f410 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 16 Jan 2021 07:13:32 +0000 Subject: [PATCH 4/9] Hopefully make the tests happy --- include/api.php | 2 +- tests/datasets/api.fixture.php | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/api.php b/include/api.php index b649d2248..26a377821 100644 --- a/include/api.php +++ b/include/api.php @@ -2041,7 +2041,7 @@ function api_statuses_repeat($type) Logger::log('API: api_statuses_repeat: '.$id); $fields = ['uri-id', 'network', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink']; - $item = Item::selectFirst($fields, ['id' => $id, 'private' => [Item::PUBLIC, Item::UNLISTED]]); + $item = Post::selectFirst($fields, ['id' => $id, 'private' => [Item::PUBLIC, Item::UNLISTED]]); if (DBA::isResult($item) && $item['body'] != "") { if (in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::TWITTER])) { diff --git a/tests/datasets/api.fixture.php b/tests/datasets/api.fixture.php index ce7161e41..fcd1e6a6b 100644 --- a/tests/datasets/api.fixture.php +++ b/tests/datasets/api.fixture.php @@ -187,6 +187,7 @@ return [ 'contact-id' => 42, 'author-id' => 42, 'owner-id' => 42, + 'causer-id' => 42, 'uid' => 42, 'verb' => 'http://activitystrea.ms/schema/1.0/post', 'unseen' => 1, @@ -210,6 +211,7 @@ return [ 'contact-id' => 42, 'author-id' => 42, 'owner-id' => 42, + 'causer-id' => 42, 'uid' => 42, 'verb' => 'http://activitystrea.ms/schema/1.0/post', 'unseen' => 0, @@ -230,6 +232,7 @@ return [ 'contact-id' => 43, 'author-id' => 43, 'owner-id' => 42, + 'causer-id' => 43, 'uid' => 42, 'verb' => 'http://activitystrea.ms/schema/1.0/post', 'unseen' => 0, @@ -249,6 +252,7 @@ return [ 'contact-id' => 44, 'author-id' => 44, 'owner-id' => 42, + 'causer-id' => 44, 'uid' => 42, 'verb' => 'http://activitystrea.ms/schema/1.0/post', 'unseen' => 0, @@ -269,6 +273,7 @@ return [ 'contact-id' => 42, 'author-id' => 42, 'owner-id' => 42, + 'causer-id' => 42, 'uid' => 42, 'verb' => 'http://activitystrea.ms/schema/1.0/post', 'unseen' => 0, @@ -292,6 +297,7 @@ return [ 'contact-id' => 44, 'author-id' => 44, 'owner-id' => 42, + 'causer-id' => 44, 'uid' => 42, 'verb' => 'http://activitystrea.ms/schema/1.0/post', 'unseen' => 0, @@ -332,6 +338,7 @@ return [ 'contact-id' => 42, 'author-id' => 42, 'owner-id' => 42, + 'causer-id' => 42, 'uid' => 42, 'wall' => 1, ], @@ -342,6 +349,7 @@ return [ 'contact-id' => 43, 'author-id' => 43, 'owner-id' => 43, + 'causer-id' => 43, 'uid' => 0, 'wall' => 1, ], @@ -352,6 +360,7 @@ return [ 'contact-id' => 44, 'author-id' => 44, 'owner-id' => 44, + 'causer-id' => 44, 'uid' => 0, 'wall' => 1, ], From bd91bb21b92bd95e12fe5d77de58739dbb9785fa Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 16 Jan 2021 07:21:02 +0000 Subject: [PATCH 5/9] No causer in threads --- tests/datasets/api.fixture.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/datasets/api.fixture.php b/tests/datasets/api.fixture.php index fcd1e6a6b..93b896ebf 100644 --- a/tests/datasets/api.fixture.php +++ b/tests/datasets/api.fixture.php @@ -338,7 +338,6 @@ return [ 'contact-id' => 42, 'author-id' => 42, 'owner-id' => 42, - 'causer-id' => 42, 'uid' => 42, 'wall' => 1, ], @@ -349,7 +348,6 @@ return [ 'contact-id' => 43, 'author-id' => 43, 'owner-id' => 43, - 'causer-id' => 43, 'uid' => 0, 'wall' => 1, ], @@ -360,7 +358,6 @@ return [ 'contact-id' => 44, 'author-id' => 44, 'owner-id' => 44, - 'causer-id' => 44, 'uid' => 0, 'wall' => 1, ], From 562e6b3f3edff82203c881367c8ec534d5a1e024 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 16 Jan 2021 07:29:57 +0000 Subject: [PATCH 6/9] Test: Possibly fixing failed test --- database.sql | 6 +++--- static/dbview.config.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/database.sql b/database.sql index 226c15133..aabb45f82 100644 --- a/database.sql +++ b/database.sql @@ -1631,15 +1631,15 @@ CREATE VIEW `post-view` AS SELECT STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id` STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id` - STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id` + LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id` LEFT JOIN `verb` ON `verb`.`id` = `item`.`vid` LEFT JOIN `event` ON `event`.`id` = `item`.`event-id` LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `item`.`uri-id` LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id` LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `item`.`uri-id` AND `item`.`origin` LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid` - STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent` - STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`; + LEFT JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent` + LEFT JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`; -- -- VIEW category-view diff --git a/static/dbview.config.php b/static/dbview.config.php index b0bf7ed61..571b5759f 100644 --- a/static/dbview.config.php +++ b/static/dbview.config.php @@ -178,15 +178,15 @@ STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id` STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id` - STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id` + LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id` LEFT JOIN `verb` ON `verb`.`id` = `item`.`vid` LEFT JOIN `event` ON `event`.`id` = `item`.`event-id` LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `item`.`uri-id` LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id` LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `item`.`uri-id` AND `item`.`origin` LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid` - STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent` - STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`" + LEFT JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent` + LEFT JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`" ], "category-view" => [ "fields" => [ From 32a4ac0c112f57f6f9ea674d6fc99b458556e93b Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 16 Jan 2021 07:36:47 +0000 Subject: [PATCH 7/9] Test: Another test for the test --- database.sql | 6 +++--- static/dbview.config.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/database.sql b/database.sql index aabb45f82..8d0d3594c 100644 --- a/database.sql +++ b/database.sql @@ -1628,9 +1628,9 @@ CREATE VIEW `post-view` AS SELECT `parent-item-author`.`name` AS `parent-author-name`, `parent-item-author`.`network` AS `parent-author-network` FROM `item` - STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id` - STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id` + LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + LEFT JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id` + LEFT JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id` LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id` LEFT JOIN `verb` ON `verb`.`id` = `item`.`vid` LEFT JOIN `event` ON `event`.`id` = `item`.`event-id` diff --git a/static/dbview.config.php b/static/dbview.config.php index 571b5759f..1772ff9ad 100644 --- a/static/dbview.config.php +++ b/static/dbview.config.php @@ -175,9 +175,9 @@ "parent-author-network" => ["parent-item-author", "network"], ], "query" => "FROM `item` - STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id` - STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id` + LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + LEFT JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id` + LEFT JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id` LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id` LEFT JOIN `verb` ON `verb`.`id` = `item`.`vid` LEFT JOIN `event` ON `event`.`id` = `item`.`event-id` From d2feb1ff7fec312d00d66ca0c41357f9baabef07 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 16 Jan 2021 07:49:20 +0000 Subject: [PATCH 8/9] Making the test work --- database.sql | 12 ++++++------ include/api.php | 2 +- static/dbview.config.php | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/database.sql b/database.sql index 8d0d3594c..226c15133 100644 --- a/database.sql +++ b/database.sql @@ -1628,18 +1628,18 @@ CREATE VIEW `post-view` AS SELECT `parent-item-author`.`name` AS `parent-author-name`, `parent-item-author`.`network` AS `parent-author-network` FROM `item` - LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - LEFT JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id` - LEFT JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id` - LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id` + STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id` + STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id` + STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id` LEFT JOIN `verb` ON `verb`.`id` = `item`.`vid` LEFT JOIN `event` ON `event`.`id` = `item`.`event-id` LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `item`.`uri-id` LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id` LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `item`.`uri-id` AND `item`.`origin` LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid` - LEFT JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent` - LEFT JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`; + STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent` + STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`; -- -- VIEW category-view diff --git a/include/api.php b/include/api.php index 26a377821..b649d2248 100644 --- a/include/api.php +++ b/include/api.php @@ -2041,7 +2041,7 @@ function api_statuses_repeat($type) Logger::log('API: api_statuses_repeat: '.$id); $fields = ['uri-id', 'network', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink']; - $item = Post::selectFirst($fields, ['id' => $id, 'private' => [Item::PUBLIC, Item::UNLISTED]]); + $item = Item::selectFirst($fields, ['id' => $id, 'private' => [Item::PUBLIC, Item::UNLISTED]]); if (DBA::isResult($item) && $item['body'] != "") { if (in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::TWITTER])) { diff --git a/static/dbview.config.php b/static/dbview.config.php index 1772ff9ad..b0bf7ed61 100644 --- a/static/dbview.config.php +++ b/static/dbview.config.php @@ -175,18 +175,18 @@ "parent-author-network" => ["parent-item-author", "network"], ], "query" => "FROM `item` - LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - LEFT JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id` - LEFT JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id` - LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id` + STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id` + STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id` + STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `item`.`causer-id` LEFT JOIN `verb` ON `verb`.`id` = `item`.`vid` LEFT JOIN `event` ON `event`.`id` = `item`.`event-id` LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `item`.`uri-id` LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id` LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `item`.`uri-id` AND `item`.`origin` LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid` - LEFT JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent` - LEFT JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`" + STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent` + STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`" ], "category-view" => [ "fields" => [ From dc2fd43c822f17c652782a7126b1bae51f213683 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 16 Jan 2021 07:35:44 -0500 Subject: [PATCH 9/9] Improve class alias naming in include/conversation --- include/conversation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index d269bc72a..326131101 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -37,7 +37,7 @@ use Friendica\Model\Post; use Friendica\Model\Profile; use Friendica\Model\Tag; use Friendica\Model\Verb; -use Friendica\Object\Post as ObjectPost; +use Friendica\Object\Post as PostObject; use Friendica\Object\Thread; use Friendica\Protocol\Activity; use Friendica\Util\Crypto; @@ -678,7 +678,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o $item['pagedrop'] = $page_dropping; if ($item['gravity'] == GRAVITY_PARENT) { - $item_object = new ObjectPost($item); + $item_object = new PostObject($item); $conv->addParent($item_object); } }