Merge pull request #9810 from annando/fixed-view
Fix "Item couldn't be fetched."
This commit is contained in:
commit
d29bad0cb2
|
@ -1,6 +1,6 @@
|
|||
-- ------------------------------------------
|
||||
-- Friendica 2021.03-dev (Red Hot Poker)
|
||||
-- DB_UPDATE_VERSION 1387
|
||||
-- DB_UPDATE_VERSION 1388
|
||||
-- ------------------------------------------
|
||||
|
||||
|
||||
|
@ -1643,7 +1643,7 @@ CREATE VIEW `post-view` AS SELECT
|
|||
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 `item` AS `parent-item` ON `parent-item`.`uri-id` = `item`.`parent-uri-id`
|
||||
STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`;
|
||||
|
||||
--
|
||||
|
|
|
@ -1881,14 +1881,14 @@ 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 = Post::selectFirst(['uri'], ['id' => $id]);
|
||||
$uri_item = Post::selectFirst(['uri-id'], ['id' => $id]);
|
||||
if (!DBA::isResult($uri_item)) {
|
||||
throw new BadRequestException("There is no status with this id.");
|
||||
throw new BadRequestException(sprintf("There is no status with the id %d", $id));
|
||||
}
|
||||
|
||||
$item = Post::selectFirst(['id'], ['uri' => $uri_item['uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
|
||||
$item = Post::selectFirst(['id'], ['uri-id' => $uri_item['uri-id'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
|
||||
if (!DBA::isResult($item)) {
|
||||
throw new BadRequestException("There is no status with this id.");
|
||||
throw new BadRequestException(sprintf("There is no status with the uri-id %d for the given user.", $uri_item['uri-id']));
|
||||
}
|
||||
|
||||
$id = $item['id'];
|
||||
|
@ -1905,7 +1905,7 @@ function api_statuses_show($type)
|
|||
|
||||
/// @TODO How about copying this to above methods which don't check $r ?
|
||||
if (!DBA::isResult($statuses)) {
|
||||
throw new BadRequestException("There is no status with this id.");
|
||||
throw new BadRequestException(sprintf("There is no status or conversation with the id %d.", $id));
|
||||
}
|
||||
|
||||
$ret = api_format_items(Post::toArray($statuses), $user_info, false, $type);
|
||||
|
@ -1964,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 = Post::selectFirst(['parent-uri'], ['id' => $id]);
|
||||
$item = Post::selectFirst(['parent-uri-id'], ['id' => $id]);
|
||||
if (!DBA::isResult($item)) {
|
||||
throw new BadRequestException("There is no status with this id.");
|
||||
}
|
||||
|
||||
$parent = Post::selectFirst(['id'], ['uri' => $item['parent-uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
|
||||
$parent = Post::selectFirst(['id'], ['uri-id' => $item['parent-uri-id'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
|
||||
if (!DBA::isResult($parent)) {
|
||||
throw new BadRequestException("There is no status with this id.");
|
||||
}
|
||||
|
@ -2171,11 +2171,11 @@ function api_statuses_mentions($type)
|
|||
|
||||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
$query = "SELECT `item`.`id` FROM `user-item`
|
||||
INNER JOIN `item` ON `item`.`id` = `user-item`.`iid` AND `item`.`gravity` IN (?, ?)
|
||||
WHERE (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`) AND
|
||||
`user-item`.`uid` = ? AND `user-item`.`notification-type` & ? != 0
|
||||
AND `user-item`.`iid` > ?";
|
||||
$query = "`gravity` IN (?, ?) AND `id` IN (SELECT `iid` FROM `user-item`
|
||||
WHERE (`hidden` IS NULL OR NOT `hidden`) AND
|
||||
`uid` = ? AND `notification-type` & ? != 0
|
||||
AND `iid` > ?";
|
||||
|
||||
$condition = [GRAVITY_PARENT, GRAVITY_COMMENT, api_user(),
|
||||
UserItem::NOTIF_EXPLICIT_TAGGED | UserItem::NOTIF_IMPLICIT_TAGGED |
|
||||
UserItem::NOTIF_THREAD_COMMENT | UserItem::NOTIF_DIRECT_COMMENT |
|
||||
|
@ -2183,23 +2183,16 @@ function api_statuses_mentions($type)
|
|||
$since_id];
|
||||
|
||||
if ($max_id > 0) {
|
||||
$query .= " AND `item`.`id` <= ?";
|
||||
$query .= " AND `iid` <= ?";
|
||||
$condition[] = $max_id;
|
||||
}
|
||||
|
||||
$query .= " ORDER BY `user-item`.`iid` DESC LIMIT ?, ?";
|
||||
$condition[] = $start;
|
||||
$condition[] = $count;
|
||||
$query .= ")";
|
||||
|
||||
$useritems = DBA::p($query, $condition);
|
||||
$itemids = [];
|
||||
while ($useritem = DBA::fetch($useritems)) {
|
||||
$itemids[] = $useritem['id'];
|
||||
}
|
||||
DBA::close($useritems);
|
||||
array_unshift($condition, $query);
|
||||
|
||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::selectForUser(api_user(), [], ['id' => $itemids], $params);
|
||||
$statuses = Post::selectForUser(api_user(), [], $condition, $params);
|
||||
|
||||
$ret = api_format_items(Post::toArray($statuses), $user_info, false, $type);
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
use Friendica\Database\DBA;
|
||||
|
||||
if (!defined('DB_UPDATE_VERSION')) {
|
||||
define('DB_UPDATE_VERSION', 1387);
|
||||
define('DB_UPDATE_VERSION', 1388);
|
||||
}
|
||||
|
||||
return [
|
||||
|
|
|
@ -190,7 +190,7 @@
|
|||
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 `item` AS `parent-item` ON `parent-item`.`uri-id` = `item`.`parent-uri-id`
|
||||
STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`"
|
||||
],
|
||||
"category-view" => [
|
||||
|
|
|
@ -193,6 +193,9 @@ return [
|
|||
'unseen' => 1,
|
||||
'body' => 'Parent status',
|
||||
'parent' => 1,
|
||||
'parent-uri-id' => 1,
|
||||
'thr-parent-id' => 1,
|
||||
'gravity' => GRAVITY_PARENT,
|
||||
'author-link' => 'http://localhost/profile/selfcontact',
|
||||
'wall' => 1,
|
||||
'starred' => 1,
|
||||
|
@ -217,6 +220,9 @@ return [
|
|||
'unseen' => 0,
|
||||
'body' => 'Reply',
|
||||
'parent' => 1,
|
||||
'parent-uri-id' => 1,
|
||||
'thr-parent-id' => 1,
|
||||
'gravity' => GRAVITY_COMMENT,
|
||||
'author-link' => 'http://localhost/profile/selfcontact',
|
||||
'wall' => 1,
|
||||
'starred' => 0,
|
||||
|
@ -238,6 +244,9 @@ return [
|
|||
'unseen' => 0,
|
||||
'body' => 'Other user status',
|
||||
'parent' => 3,
|
||||
'parent-uri-id' => 3,
|
||||
'thr-parent-id' => 3,
|
||||
'gravity' => GRAVITY_PARENT,
|
||||
'author-link' => 'http://localhost/profile/othercontact',
|
||||
'wall' => 1,
|
||||
'starred' => 0,
|
||||
|
@ -258,6 +267,9 @@ return [
|
|||
'unseen' => 0,
|
||||
'body' => 'Friend user reply',
|
||||
'parent' => 1,
|
||||
'parent-uri-id' => 1,
|
||||
'thr-parent-id' => 1,
|
||||
'gravity' => GRAVITY_COMMENT,
|
||||
'author-link' => 'http://localhost/profile/othercontact',
|
||||
'wall' => 1,
|
||||
'starred' => 0,
|
||||
|
@ -279,6 +291,9 @@ return [
|
|||
'unseen' => 0,
|
||||
'body' => '[share]Shared status[/share]',
|
||||
'parent' => 1,
|
||||
'parent-uri-id' => 1,
|
||||
'thr-parent-id' => 1,
|
||||
'gravity' => GRAVITY_COMMENT,
|
||||
'author-link' => 'http://localhost/profile/othercontact',
|
||||
'wall' => 1,
|
||||
'starred' => 0,
|
||||
|
@ -303,6 +318,9 @@ return [
|
|||
'unseen' => 0,
|
||||
'body' => 'Friend user status',
|
||||
'parent' => 6,
|
||||
'parent-uri-id' => 6,
|
||||
'thr-parent-id' => 6,
|
||||
'gravity' => GRAVITY_PARENT,
|
||||
'author-link' => 'http://localhost/profile/othercontact',
|
||||
'wall' => 1,
|
||||
'starred' => 0,
|
||||
|
|
Loading…
Reference in New Issue
Block a user