mirror of
https://github.com/friendica/friendica
synced 2024-12-22 18:00:16 +00:00
Issue 9906: Improved view speed
This commit is contained in:
parent
ab5a447bc2
commit
f1377ce7fb
7 changed files with 76 additions and 50 deletions
51
database.sql
51
database.sql
|
@ -1,6 +1,6 @@
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
-- Friendica 2021.03-dev (Red Hot Poker)
|
-- Friendica 2021.03-dev (Red Hot Poker)
|
||||||
-- DB_UPDATE_VERSION 1398
|
-- DB_UPDATE_VERSION 1399
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -1164,12 +1164,24 @@ CREATE TABLE IF NOT EXISTS `post-thread-user` (
|
||||||
`mention` boolean NOT NULL DEFAULT '0' COMMENT '',
|
`mention` boolean NOT NULL DEFAULT '0' COMMENT '',
|
||||||
`pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
|
`pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
|
||||||
`forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
|
`forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
|
||||||
|
`contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
|
||||||
|
`unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
|
||||||
|
`hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
|
||||||
|
`origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
|
||||||
|
`psid` int unsigned COMMENT 'ID of the permission set of this post',
|
||||||
|
`post-user-id` int unsigned COMMENT 'Id of the post-user table',
|
||||||
PRIMARY KEY(`uid`,`uri-id`),
|
PRIMARY KEY(`uid`,`uri-id`),
|
||||||
INDEX `uid_wall` (`uid`,`wall`),
|
INDEX `uid_wall` (`uid`,`wall`),
|
||||||
INDEX `uid_pinned` (`uid`,`pinned`),
|
INDEX `uid_pinned` (`uid`,`pinned`),
|
||||||
INDEX `uri-id` (`uri-id`),
|
INDEX `uri-id` (`uri-id`),
|
||||||
|
INDEX `contact-id` (`contact-id`),
|
||||||
|
INDEX `psid` (`psid`),
|
||||||
|
INDEX `post-user-id` (`post-user-id`),
|
||||||
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
|
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
|
||||||
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
|
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
|
||||||
|
FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
|
||||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
|
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
|
||||||
|
|
||||||
--
|
--
|
||||||
|
@ -1191,6 +1203,7 @@ CREATE TABLE IF NOT EXISTS `post-user` (
|
||||||
INDEX `uri-id` (`uri-id`),
|
INDEX `uri-id` (`uri-id`),
|
||||||
INDEX `contact-id` (`contact-id`),
|
INDEX `contact-id` (`contact-id`),
|
||||||
INDEX `psid` (`psid`),
|
INDEX `psid` (`psid`),
|
||||||
|
INDEX `uid_hidden` (`uid`,`hidden`),
|
||||||
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
|
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
|
||||||
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
|
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
|
||||||
FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
|
FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
|
||||||
|
@ -1645,15 +1658,15 @@ CREATE VIEW `post-thread-view` AS SELECT
|
||||||
`item`.`visible` AS `visible`,
|
`item`.`visible` AS `visible`,
|
||||||
`post-thread-user`.`starred` AS `starred`,
|
`post-thread-user`.`starred` AS `starred`,
|
||||||
`item`.`bookmark` AS `bookmark`,
|
`item`.`bookmark` AS `bookmark`,
|
||||||
`post-user`.`unseen` AS `unseen`,
|
`post-thread-user`.`unseen` AS `unseen`,
|
||||||
`item`.`deleted` AS `deleted`,
|
`item`.`deleted` AS `deleted`,
|
||||||
`post-user`.`origin` AS `origin`,
|
`post-thread-user`.`origin` AS `origin`,
|
||||||
`post-thread-user`.`forum_mode` AS `forum_mode`,
|
`post-thread-user`.`forum_mode` AS `forum_mode`,
|
||||||
`item`.`mention` AS `mention`,
|
`item`.`mention` AS `mention`,
|
||||||
`item`.`global` AS `global`,
|
`item`.`global` AS `global`,
|
||||||
`post-thread`.`network` AS `network`,
|
`post-thread`.`network` AS `network`,
|
||||||
`item`.`vid` AS `vid`,
|
`item`.`vid` AS `vid`,
|
||||||
`post-user`.`psid` AS `psid`,
|
`post-thread-user`.`psid` AS `psid`,
|
||||||
IF (`item`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
|
IF (`item`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
|
||||||
`post-content`.`title` AS `title`,
|
`post-content`.`title` AS `title`,
|
||||||
`post-content`.`content-warning` AS `content-warning`,
|
`post-content`.`content-warning` AS `content-warning`,
|
||||||
|
@ -1671,7 +1684,7 @@ CREATE VIEW `post-thread-view` AS SELECT
|
||||||
`post-content`.`target-type` AS `target-type`,
|
`post-content`.`target-type` AS `target-type`,
|
||||||
`post-content`.`target` AS `target`,
|
`post-content`.`target` AS `target`,
|
||||||
`post-content`.`resource-id` AS `resource-id`,
|
`post-content`.`resource-id` AS `resource-id`,
|
||||||
`post-user`.`contact-id` AS `contact-id`,
|
`post-thread-user`.`contact-id` AS `contact-id`,
|
||||||
`contact`.`url` AS `contact-link`,
|
`contact`.`url` AS `contact-link`,
|
||||||
`contact`.`addr` AS `contact-addr`,
|
`contact`.`addr` AS `contact-addr`,
|
||||||
`contact`.`name` AS `contact-name`,
|
`contact`.`name` AS `contact-name`,
|
||||||
|
@ -1729,10 +1742,10 @@ CREATE VIEW `post-thread-view` AS SELECT
|
||||||
`post-delivery-data`.`queue_count` AS `delivery_queue_count`,
|
`post-delivery-data`.`queue_count` AS `delivery_queue_count`,
|
||||||
`post-delivery-data`.`queue_done` AS `delivery_queue_done`,
|
`post-delivery-data`.`queue_done` AS `delivery_queue_done`,
|
||||||
`post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
|
`post-delivery-data`.`queue_failed` AS `delivery_queue_failed`,
|
||||||
IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
|
IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`) AS `allow_cid`,
|
||||||
IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
|
IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`) AS `allow_gid`,
|
||||||
IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
|
IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`) AS `deny_cid`,
|
||||||
IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
|
IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`) AS `deny_gid`,
|
||||||
`item`.`event-id` AS `event-id`,
|
`item`.`event-id` AS `event-id`,
|
||||||
`event`.`created` AS `event-created`,
|
`event`.`created` AS `event-created`,
|
||||||
`event`.`edited` AS `event-edited`,
|
`event`.`edited` AS `event-edited`,
|
||||||
|
@ -1754,9 +1767,8 @@ CREATE VIEW `post-thread-view` AS SELECT
|
||||||
`parent-item-author`.`network` AS `parent-author-network`
|
`parent-item-author`.`network` AS `parent-author-network`
|
||||||
FROM `post-thread`
|
FROM `post-thread`
|
||||||
STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-thread`.`uri-id`
|
STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-thread`.`uri-id`
|
||||||
STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-thread`.`uri-id`
|
|
||||||
STRAIGHT_JOIN `item` ON `item`.`uri-id` = `post-thread`.`uri-id` AND `item`.`uid` = `post-thread-user`.`uid`
|
STRAIGHT_JOIN `item` ON `item`.`uri-id` = `post-thread`.`uri-id` AND `item`.`uid` = `post-thread-user`.`uid`
|
||||||
STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
|
STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
|
||||||
STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
|
STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
|
||||||
STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
|
STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
|
||||||
STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
|
STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
|
||||||
|
@ -1764,8 +1776,8 @@ CREATE VIEW `post-thread-view` AS SELECT
|
||||||
LEFT JOIN `event` ON `event`.`id` = `item`.`event-id`
|
LEFT JOIN `event` ON `event`.`id` = `item`.`event-id`
|
||||||
LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
|
LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
|
||||||
LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
|
LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
|
||||||
LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread`.`uri-id` AND `post-user`.`origin`
|
LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread`.`uri-id` AND `post-thread-user`.`origin`
|
||||||
LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
|
LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
|
||||||
STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent`
|
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`;
|
STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`;
|
||||||
|
|
||||||
|
@ -1852,19 +1864,18 @@ CREATE VIEW `network-thread-view` AS SELECT
|
||||||
`post-thread-user`.`starred` AS `starred`,
|
`post-thread-user`.`starred` AS `starred`,
|
||||||
`post-thread-user`.`mention` AS `mention`,
|
`post-thread-user`.`mention` AS `mention`,
|
||||||
`post-thread`.`network` AS `network`,
|
`post-thread`.`network` AS `network`,
|
||||||
`post-user`.`contact-id` AS `contact-id`,
|
`post-thread-user`.`contact-id` AS `contact-id`,
|
||||||
`ownercontact`.`contact-type` AS `contact-type`
|
`ownercontact`.`contact-type` AS `contact-type`
|
||||||
FROM `post-thread`
|
FROM `post-thread`
|
||||||
STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-thread`.`uri-id`
|
STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-thread`.`uri-id`
|
||||||
STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-thread`.`uri-id` AND `post-user`.`uid` = `post-thread-user`.`uid`
|
|
||||||
STRAIGHT_JOIN `item` ON `item`.`uri-id` = `post-thread`.`uri-id` AND `item`.`uid` = `post-thread-user`.`uid`
|
STRAIGHT_JOIN `item` ON `item`.`uri-id` = `post-thread`.`uri-id` AND `item`.`uid` = `post-thread-user`.`uid`
|
||||||
STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
|
STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
|
||||||
LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-user`.`uid` AND `author`.`cid` = `post-thread`.`author-id`
|
LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread`.`author-id`
|
||||||
LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-user`.`uid` AND `owner`.`cid` = `post-thread`.`owner-id`
|
LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread`.`owner-id`
|
||||||
LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread`.`owner-id`
|
LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread`.`owner-id`
|
||||||
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
|
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
|
||||||
AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
|
AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
|
||||||
AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
|
AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
|
||||||
AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
|
AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
|
||||||
AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
|
AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`);
|
||||||
|
|
||||||
|
|
|
@ -1015,6 +1015,7 @@ class Item
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||||
|
$item['post-user-id'] = $id;
|
||||||
Post\ThreadUser::insert($item['uri-id'], $item['uid'], $item);
|
Post\ThreadUser::insert($item['uri-id'], $item['uid'], $item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -464,12 +464,7 @@ class Post
|
||||||
if (!empty($update_fields)) {
|
if (!empty($update_fields)) {
|
||||||
$rows = DBA::selectToArray('post-view', ['post-user-id'], $thread_condition);
|
$rows = DBA::selectToArray('post-view', ['post-user-id'], $thread_condition);
|
||||||
$thread_puids = array_column($rows, 'post-user-id');
|
$thread_puids = array_column($rows, 'post-user-id');
|
||||||
|
if (!DBA::update('post-thread-user', $update_fields, ['post-user-id' => $thread_puids])) {
|
||||||
$post_thread_condition = DBA::collapseCondition(['id' => $thread_puids]);
|
|
||||||
|
|
||||||
$post_thread_condition[0] = "EXISTS(SELECT `id` FROM `post-user` WHERE " .
|
|
||||||
$post_thread_condition[0] . " AND `uri-id` = `post-thread-user`.`uri-id` AND `uid` = `post-thread-user`.`uid`)";
|
|
||||||
if (!DBA::update('post-thread-user', $update_fields, $post_thread_condition)) {
|
|
||||||
DBA::rollback();
|
DBA::rollback();
|
||||||
Logger::notice('Updating post-thread-user failed', ['fields' => $update_fields, 'condition' => $condition]);
|
Logger::notice('Updating post-thread-user failed', ['fields' => $update_fields, 'condition' => $condition]);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
|
||||||
if (!defined('DB_UPDATE_VERSION')) {
|
if (!defined('DB_UPDATE_VERSION')) {
|
||||||
define('DB_UPDATE_VERSION', 1398);
|
define('DB_UPDATE_VERSION', 1399);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -1215,13 +1215,22 @@ return [
|
||||||
"wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "This item was posted to the wall of uid"],
|
"wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "This item was posted to the wall of uid"],
|
||||||
"mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
|
"mention" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
|
||||||
"pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
|
"pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
|
||||||
"forum_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""]
|
"forum_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
|
||||||
|
"contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id"], "comment" => "contact.id"],
|
||||||
|
"unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => "post has not been seen"],
|
||||||
|
"hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marker to hide the post from the user"],
|
||||||
|
"origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item originated at this site"],
|
||||||
|
"psid" => ["type" => "int unsigned", "foreign" => ["permissionset" => "id", "on delete" => "restrict"], "comment" => "ID of the permission set of this post"],
|
||||||
|
"post-user-id" => ["type" => "int unsigned", "foreign" => ["post-user" => "id"], "comment" => "Id of the post-user table"],
|
||||||
],
|
],
|
||||||
"indexes" => [
|
"indexes" => [
|
||||||
"PRIMARY" => ["uid", "uri-id"],
|
"PRIMARY" => ["uid", "uri-id"],
|
||||||
"uid_wall" => ["uid", "wall"],
|
"uid_wall" => ["uid", "wall"],
|
||||||
"uid_pinned" => ["uid", "pinned"],
|
"uid_pinned" => ["uid", "pinned"],
|
||||||
"uri-id" => ["uri-id"],
|
"uri-id" => ["uri-id"],
|
||||||
|
"contact-id" => ["contact-id"],
|
||||||
|
"psid" => ["psid"],
|
||||||
|
"post-user-id" => ["post-user-id"],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"post-user" => [
|
"post-user" => [
|
||||||
|
@ -1244,6 +1253,7 @@ return [
|
||||||
"uri-id" => ["uri-id"],
|
"uri-id" => ["uri-id"],
|
||||||
"contact-id" => ["contact-id"],
|
"contact-id" => ["contact-id"],
|
||||||
"psid" => ["psid"],
|
"psid" => ["psid"],
|
||||||
|
"uid_hidden" => ["uid", "hidden"],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
"post-user-notification" => [
|
"post-user-notification" => [
|
||||||
|
|
|
@ -221,15 +221,15 @@
|
||||||
"visible" => ["item", "visible"],
|
"visible" => ["item", "visible"],
|
||||||
"starred" => ["post-thread-user", "starred"],
|
"starred" => ["post-thread-user", "starred"],
|
||||||
"bookmark" => ["item", "bookmark"],
|
"bookmark" => ["item", "bookmark"],
|
||||||
"unseen" => ["post-user", "unseen"],
|
"unseen" => ["post-thread-user", "unseen"],
|
||||||
"deleted" => ["item", "deleted"],
|
"deleted" => ["item", "deleted"],
|
||||||
"origin" => ["post-user", "origin"],
|
"origin" => ["post-thread-user", "origin"],
|
||||||
"forum_mode" => ["post-thread-user", "forum_mode"],
|
"forum_mode" => ["post-thread-user", "forum_mode"],
|
||||||
"mention" => ["item", "mention"],
|
"mention" => ["item", "mention"],
|
||||||
"global" => ["item", "global"],
|
"global" => ["item", "global"],
|
||||||
"network" => ["post-thread", "network"],
|
"network" => ["post-thread", "network"],
|
||||||
"vid" => ["item", "vid"],
|
"vid" => ["item", "vid"],
|
||||||
"psid" => ["post-user", "psid"],
|
"psid" => ["post-thread-user", "psid"],
|
||||||
"verb" => "IF (`item`.`vid` IS NULL, '', `verb`.`name`)",
|
"verb" => "IF (`item`.`vid` IS NULL, '', `verb`.`name`)",
|
||||||
"title" => ["post-content", "title"],
|
"title" => ["post-content", "title"],
|
||||||
"content-warning" => ["post-content", "content-warning"],
|
"content-warning" => ["post-content", "content-warning"],
|
||||||
|
@ -247,7 +247,7 @@
|
||||||
"target-type" => ["post-content", "target-type"],
|
"target-type" => ["post-content", "target-type"],
|
||||||
"target" => ["post-content", "target"],
|
"target" => ["post-content", "target"],
|
||||||
"resource-id" => ["post-content", "resource-id"],
|
"resource-id" => ["post-content", "resource-id"],
|
||||||
"contact-id" => ["post-user", "contact-id"],
|
"contact-id" => ["post-thread-user", "contact-id"],
|
||||||
"contact-link" => ["contact", "url"],
|
"contact-link" => ["contact", "url"],
|
||||||
"contact-addr" => ["contact", "addr"],
|
"contact-addr" => ["contact", "addr"],
|
||||||
"contact-name" => ["contact", "name"],
|
"contact-name" => ["contact", "name"],
|
||||||
|
@ -305,10 +305,10 @@
|
||||||
"delivery_queue_count" => ["post-delivery-data", "queue_count"],
|
"delivery_queue_count" => ["post-delivery-data", "queue_count"],
|
||||||
"delivery_queue_done" => ["post-delivery-data", "queue_done"],
|
"delivery_queue_done" => ["post-delivery-data", "queue_done"],
|
||||||
"delivery_queue_failed" => ["post-delivery-data", "queue_failed"],
|
"delivery_queue_failed" => ["post-delivery-data", "queue_failed"],
|
||||||
"allow_cid" => "IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`)",
|
"allow_cid" => "IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`)",
|
||||||
"allow_gid" => "IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`)",
|
"allow_gid" => "IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`)",
|
||||||
"deny_cid" => "IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`)",
|
"deny_cid" => "IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`)",
|
||||||
"deny_gid" => "IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`)",
|
"deny_gid" => "IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`)",
|
||||||
"event-id" => ["item", "event-id"],
|
"event-id" => ["item", "event-id"],
|
||||||
"event-created" => ["event", "created"],
|
"event-created" => ["event", "created"],
|
||||||
"event-edited" => ["event", "edited"],
|
"event-edited" => ["event", "edited"],
|
||||||
|
@ -331,9 +331,8 @@
|
||||||
],
|
],
|
||||||
"query" => "FROM `post-thread`
|
"query" => "FROM `post-thread`
|
||||||
STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-thread`.`uri-id`
|
STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-thread`.`uri-id`
|
||||||
STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-thread`.`uri-id`
|
|
||||||
STRAIGHT_JOIN `item` ON `item`.`uri-id` = `post-thread`.`uri-id` AND `item`.`uid` = `post-thread-user`.`uid`
|
STRAIGHT_JOIN `item` ON `item`.`uri-id` = `post-thread`.`uri-id` AND `item`.`uid` = `post-thread-user`.`uid`
|
||||||
STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
|
STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
|
||||||
STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
|
STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
|
||||||
STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
|
STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread`.`owner-id`
|
||||||
STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
|
STRAIGHT_JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread`.`causer-id`
|
||||||
|
@ -341,8 +340,8 @@
|
||||||
LEFT JOIN `event` ON `event`.`id` = `item`.`event-id`
|
LEFT JOIN `event` ON `event`.`id` = `item`.`event-id`
|
||||||
LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
|
LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
|
||||||
LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
|
LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
|
||||||
LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread`.`uri-id` AND `post-user`.`origin`
|
LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread`.`uri-id` AND `post-thread-user`.`origin`
|
||||||
LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
|
LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
|
||||||
STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent`
|
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`"
|
STRAIGHT_JOIN `contact` AS `parent-item-author` ON `parent-item-author`.`id` = `parent-item`.`author-id`"
|
||||||
],
|
],
|
||||||
|
@ -420,20 +419,19 @@
|
||||||
"starred" => ["post-thread-user", "starred"],
|
"starred" => ["post-thread-user", "starred"],
|
||||||
"mention" => ["post-thread-user", "mention"],
|
"mention" => ["post-thread-user", "mention"],
|
||||||
"network" => ["post-thread", "network"],
|
"network" => ["post-thread", "network"],
|
||||||
"contact-id" => ["post-user", "contact-id"],
|
"contact-id" => ["post-thread-user", "contact-id"],
|
||||||
"contact-type" => ["ownercontact", "contact-type"],
|
"contact-type" => ["ownercontact", "contact-type"],
|
||||||
],
|
],
|
||||||
"query" => "FROM `post-thread`
|
"query" => "FROM `post-thread`
|
||||||
STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-thread`.`uri-id`
|
STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-thread`.`uri-id`
|
||||||
STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-thread`.`uri-id` AND `post-user`.`uid` = `post-thread-user`.`uid`
|
|
||||||
STRAIGHT_JOIN `item` ON `item`.`uri-id` = `post-thread`.`uri-id` AND `item`.`uid` = `post-thread-user`.`uid`
|
STRAIGHT_JOIN `item` ON `item`.`uri-id` = `post-thread`.`uri-id` AND `item`.`uid` = `post-thread-user`.`uid`
|
||||||
STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
|
STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
|
||||||
LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-user`.`uid` AND `author`.`cid` = `post-thread`.`author-id`
|
LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread`.`author-id`
|
||||||
LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-user`.`uid` AND `owner`.`cid` = `post-thread`.`owner-id`
|
LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread`.`owner-id`
|
||||||
LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread`.`owner-id`
|
LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread`.`owner-id`
|
||||||
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
|
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
|
||||||
AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
|
AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
|
||||||
AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
|
AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
|
||||||
AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
|
AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
|
||||||
AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
|
AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
|
||||||
],
|
],
|
||||||
|
|
|
@ -220,21 +220,21 @@ return [
|
||||||
'author-id' => 42,
|
'author-id' => 42,
|
||||||
'owner-id' => 42,
|
'owner-id' => 42,
|
||||||
'causer-id' => 42,
|
'causer-id' => 42,
|
||||||
'network' => Protocol::DFRN,
|
'network' => Protocol::DFRN,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'uri-id' => 3,
|
'uri-id' => 3,
|
||||||
'author-id' => 43,
|
'author-id' => 43,
|
||||||
'owner-id' => 43,
|
'owner-id' => 43,
|
||||||
'causer-id' => 43,
|
'causer-id' => 43,
|
||||||
'network' => Protocol::DFRN,
|
'network' => Protocol::DFRN,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'uri-id' => 6,
|
'uri-id' => 6,
|
||||||
'author-id' => 44,
|
'author-id' => 44,
|
||||||
'owner-id' => 44,
|
'owner-id' => 44,
|
||||||
'causer-id' => 44,
|
'causer-id' => 44,
|
||||||
'network' => Protocol::DFRN,
|
'network' => Protocol::DFRN,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'post-thread-user' => [
|
'post-thread-user' => [
|
||||||
|
|
13
update.php
13
update.php
|
@ -757,5 +757,16 @@ function update_1398()
|
||||||
}
|
}
|
||||||
|
|
||||||
return Update::SUCCESS;
|
return Update::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_1399()
|
||||||
|
{
|
||||||
|
if (!DBA::e("UPDATE `post-thread-user` INNER JOIN `post-user` ON `post-user`.`uid` = `post-thread-user`.`uid` AND `post-user`.`uri-id` = `post-thread-user`.`uri-id`
|
||||||
|
SET `post-thread-user`.`contact-id` = `post-user`.`contact-id`, `post-thread-user`.`unseen` = `post-user`.`unseen`,
|
||||||
|
`post-thread-user`.`hidden` = `post-user`.`hidden`, `post-thread-user`.`origin` = `post-user`.`origin`,
|
||||||
|
`post-thread-user`.`psid` = `post-user`.`psid`, `post-thread-user`.`post-user-id` = `post-user`.`id`")) {
|
||||||
|
return Update::FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Update::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue