-- ------------------------------------------
-- Friendica 2021.03-dev (Red Hot Poker)
--- DB_UPDATE_VERSION 1400
+-- DB_UPDATE_VERSION 1401
-- ------------------------------------------
`msg` mediumtext COMMENT '',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
`link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
- `iid` int unsigned COMMENT 'item.id',
+ `iid` int unsigned COMMENT '',
`parent` int unsigned COMMENT '',
`uri-id` int unsigned COMMENT 'Item-uri id of the related post',
`parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
CREATE TABLE IF NOT EXISTS `notify-threads` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
- `master-parent-item` int unsigned COMMENT '',
+ `master-parent-item` int unsigned COMMENT 'Deprecated',
`master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
`parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
`receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
PRIMARY KEY(`id`),
- INDEX `master-parent-item` (`master-parent-item`),
INDEX `master-parent-uri-id` (`master-parent-uri-id`),
INDEX `receiver-uid` (`receiver-uid`),
INDEX `notify-id` (`notify-id`),
FOREIGN KEY (`notify-id`) REFERENCES `notify` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
- FOREIGN KEY (`master-parent-item`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`master-parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`receiver-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
CREATE VIEW `post-thread-view` AS SELECT
`post-user`.`id` AS `id`,
`item`.`id` AS `item-id`,
- `post-user`.`id` AS `iid`,
`post-user`.`id` AS `post-user-id`,
`post-thread-user`.`uid` AS `uid`,
`parent-post`.`id` AS `parent`,
}
$fields = ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
- 'type', 'body', 'title', 'uri-id', 'wall', 'post-type', 'guid'];
+ 'body', 'title', 'uri-id', 'wall', 'post-type', 'guid'];
$item = Post::selectFirstForUser(local_user(), $fields, ['id' => $post_id, 'uid' => local_user()]);
$selected = array_merge(Item::DISPLAY_FIELDLIST, Item::ITEM_FIELDLIST);
if ($view == 'post-thread-view') {
- $selected = array_merge($selected, ['ignored', 'iid']);
+ $selected = array_merge($selected, ['ignored']);
}
}
$last_updated = $last_updated_array[$last_updated_key] ?? 0;
- // If the page user is the owner of the page we should query for unseen
- // items. Otherwise use a timestamp of the last succesful update request.
- if ($is_owner || !$last_updated) {
+ if ($_GET['force'] && !empty($_GET['item'])) {
+ // When the parent is provided, we only fetch this
+ $sql_extra4 = " AND `parent` = " . intval($_GET['item']);
+ } elseif ($is_owner || !$last_updated) {
+ // If the page user is the owner of the page we should query for unseen
+ // items. Otherwise use a timestamp of the last succesful update request.
$sql_extra4 = " AND `unseen`";
} else {
$gmupdate = gmdate(DateTimeFormat::MYSQL, $last_updated);
*/
class RemoveContact {
public static function execute($id) {
+ if (empty($id)) {
+ return;
+ }
+
// Only delete if the contact is to be deleted
$contact = DBA::selectFirst('contact', ['uid'], ['deleted' => true, 'id' => $id]);
if (!DBA::isResult($contact)) {
} else {
$condition = ['uid' => $contact['uid'], 'contact-id' => $id];
}
- do {
- $items = Post::select(['item-id', 'post-user-id', 'uri-id', 'guid'], $condition, ['limit' => 100]);
- while ($item = Post::fetch($items)) {
- Logger::info('Delete removed contact item', ['id' => $item['item-id'], 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
- if (DBStructure::existsTable('item')) {
- DBA::delete('item', ['id' => $item['item-id']]);
+ if (DBStructure::existsTable('item')) {
+ do {
+ $items = Post::select(['item-id', 'post-user-id', 'uri-id', 'guid'], $condition, ['limit' => 100]);
+ while ($item = Post::fetch($items)) {
+ Logger::info('Delete removed contact item', ['id' => $item['item-id'], 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
+ DBA::delete('item', ['id' => $item['item-id']]);
}
- Post::delete(['uri-id' => $item['uri-id']]);
- Post\ThreadUser::delete(['post-user-id' => $item['post-user-id']]);
- Post\Thread::delete(['uri-id' => $item['uri-id']]);
- Post\User::delete(['id' => $item['post-user-id']]);
- }
- DBA::close($items);
- } while (Post::exists($condition));
+ DBA::close($items);
+ } while (Post::exists($condition));
+ }
+
+ Post\User::delete(['author-id' => $id]);
+ Post\User::delete(['owner-id' => $id]);
+ Post\User::delete(['causer-id' => $id]);
+ Post\User::delete(['contact-id' => $id]);
+ Post\ThreadUser::delete(['author-id' => $id]);
+ Post\ThreadUser::delete(['owner-id' => $id]);
+ Post\ThreadUser::delete(['causer-id' => $id]);
+ Post\ThreadUser::delete(['contact-id' => $id]);
+ Post\Thread::delete(['author-id' => $id]);
+ Post\Thread::delete(['owner-id' => $id]);
+ Post\Thread::delete(['causer-id' => $id]);
+ Post::delete(['author-id' => $id]);
+ Post::delete(['owner-id' => $id]);
+ Post::delete(['causer-id' => $id]);
Photo::delete(['contact-id' => $id]);
$ret = DBA::delete('contact', ['id' => $id]);
use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) {
- define('DB_UPDATE_VERSION', 1400);
+ define('DB_UPDATE_VERSION', 1401);
}
return [
"msg" => ["type" => "mediumtext", "comment" => ""],
"uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "foreign" => ["user" => "uid"], "comment" => "Owner User id"],
"link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
- "iid" => ["type" => "int unsigned", "relation" => ["item" => "id"], "comment" => "item.id"],
- "parent" => ["type" => "int unsigned", "relation" => ["item" => "id"], "comment" => ""],
+ "iid" => ["type" => "int unsigned", "comment" => ""],
+ "parent" => ["type" => "int unsigned", "comment" => ""],
"uri-id" => ["type" => "int unsigned", "foreign" => ["item-uri" => "id"], "comment" => "Item-uri id of the related post"],
"parent-uri-id" => ["type" => "int unsigned", "foreign" => ["item-uri" => "id"], "comment" => "Item-uri id of the parent of the related post"],
"seen" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"fields" => [
"id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
"notify-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["notify" => "id"], "comment" => ""],
- "master-parent-item" => ["type" => "int unsigned", "foreign" => ["item" => "id"], "comment" => ""],
+ "master-parent-item" => ["type" => "int unsigned", "comment" => "Deprecated"],
"master-parent-uri-id" => ["type" => "int unsigned", "foreign" => ["item-uri" => "id"], "comment" => "Item-uri id of the parent of the related post"],
"parent-item" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
"receiver-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "foreign" => ["user" => "uid"],
],
"indexes" => [
"PRIMARY" => ["id"],
- "master-parent-item" => ["master-parent-item"],
"master-parent-uri-id" => ["master-parent-uri-id"],
"receiver-uid" => ["receiver-uid"],
"notify-id" => ["notify-id"],
"fields" => [
"id" => ["post-user", "id"],
"item-id" => ["item", "id"],
- "iid" => ["post-user", "id"],
"post-user-id" => ["post-user", "id"],
"uid" => ["post-thread-user", "uid"],
"parent" => ["parent-post", "id"],