forked from GNUsocial/gnu-social
[CORE] Another fix for the inboxnoticestream query
This commit is contained in:
parent
d705bcbd98
commit
e2e3c1cdcd
@ -107,19 +107,26 @@ class RawInboxNoticeStream extends FullNoticeStream
|
|||||||
$notice->whereAdd(sprintf('notice.created > "%s"', $notice->escape($this->target->created)));
|
$notice->whereAdd(sprintf('notice.created > "%s"', $notice->escape($this->target->created)));
|
||||||
// Reply:: is a table of mentions
|
// Reply:: is a table of mentions
|
||||||
// Subscription:: is a table of subscriptions (every user is subscribed to themselves)
|
// Subscription:: is a table of subscriptions (every user is subscribed to themselves)
|
||||||
// Sort in descending order as id will give us even really old posts,
|
$notice->_join .= sprintf(
|
||||||
// which were recently imported. For example, if a remote instance had
|
"\n" . <<<'END'
|
||||||
// problems and just managed to post here.
|
LEFT JOIN (
|
||||||
$notice->whereAdd(
|
SELECT id FROM notice
|
||||||
sprintf('id IN (SELECT DISTINCT id FROM (' .
|
WHERE profile_id
|
||||||
'(SELECT id FROM notice WHERE profile_id IN (SELECT subscribed FROM subscription WHERE subscriber = %1$d)) UNION ' .
|
IN (SELECT subscribed FROM subscription WHERE subscriber = %1$d)
|
||||||
'(SELECT notice_id AS id FROM reply WHERE profile_id = %1$d) UNION ' .
|
UNION ALL
|
||||||
'(SELECT notice_id AS id FROM attention WHERE profile_id = %1$d) UNION ' .
|
SELECT notice_id AS id FROM reply WHERE profile_id = %1$d
|
||||||
'(SELECT notice_id AS id FROM group_inbox WHERE group_id IN (SELECT group_id FROM group_member WHERE profile_id = %1$d)) ' .
|
UNION ALL
|
||||||
'ORDER BY id DESC) AS T)',
|
SELECT notice_id AS id FROM attention WHERE profile_id = %1$d
|
||||||
$this->target->getID())
|
UNION ALL
|
||||||
|
SELECT notice_id AS id FROM group_inbox INNER JOIN group_member USING (group_id)
|
||||||
|
WHERE group_member.profile_id = %1$d
|
||||||
|
) AS t1 USING (id)
|
||||||
|
END,
|
||||||
|
$this->target->getID()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$notice->whereAdd('t1.id IS NOT NULL');
|
||||||
|
|
||||||
if (!empty($since_id)) {
|
if (!empty($since_id)) {
|
||||||
$notice->whereAdd(sprintf('notice.id > %d', $since_id));
|
$notice->whereAdd(sprintf('notice.id > %d', $since_id));
|
||||||
}
|
}
|
||||||
@ -129,6 +136,11 @@ class RawInboxNoticeStream extends FullNoticeStream
|
|||||||
|
|
||||||
self::filterVerbs($notice, $this->selectVerbs);
|
self::filterVerbs($notice, $this->selectVerbs);
|
||||||
|
|
||||||
|
// notice.id will give us even really old posts, which were recently
|
||||||
|
// imported. For example if a remote instance had problems and just
|
||||||
|
// managed to post here.
|
||||||
|
$notice->orderBy('id DESC');
|
||||||
|
|
||||||
$notice->limit($offset, $limit);
|
$notice->limit($offset, $limit);
|
||||||
|
|
||||||
if (!$notice->find()) {
|
if (!$notice->find()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user