The item table is now completely removed
This commit is contained in:
@@ -78,7 +78,7 @@ class DBStructure
|
||||
return;
|
||||
}
|
||||
|
||||
$old_tables = ['fserver', 'gcign', 'gcontact', 'gcontact-relation', 'gfollower' ,'glink', 'item-delivery-data',
|
||||
$old_tables = ['fserver', 'gcign', 'gcontact', 'gcontact-relation', 'gfollower' ,'glink', 'item', 'item-delivery-data',
|
||||
'item-activity', 'item-content', 'item_id', 'participation', 'poll', 'poll_result', 'queue', 'retriever_rule',
|
||||
'sign', 'spam', 'term', 'thread', 'user-item'];
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ class UserNotification
|
||||
return;
|
||||
}
|
||||
|
||||
Logger::info('Set notification', ['iid' => $item['id'], 'uri-id' => $item['uri-id'], 'uid' => $uid, 'notification-type' => $notification_type]);
|
||||
Logger::info('Set notification', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'notification-type' => $notification_type]);
|
||||
|
||||
$fields = ['notification-type' => $notification_type];
|
||||
Post\User::update($item['uri-id'], $uid, $fields);
|
||||
|
||||
@@ -1143,7 +1143,7 @@ class Processor
|
||||
|
||||
$implicit_mentions = [];
|
||||
if (empty($parent_author['url'])) {
|
||||
Logger::notice('Author public contact unknown.', ['author-link' => $parent['author-link'], 'item-id' => $parent['id']]);
|
||||
Logger::notice('Author public contact unknown.', ['author-link' => $parent['author-link'], 'parent-id' => $parent['id']]);
|
||||
} else {
|
||||
$implicit_mentions[] = $parent_author['url'];
|
||||
$implicit_mentions[] = $parent_author['nurl'];
|
||||
|
||||
@@ -54,19 +54,6 @@ class APDelivery
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($uri_id) && !empty($item_id)) {
|
||||
$item = Post::selectFirst(['uri-id', 'id'], ['item-id' => $item_id]);
|
||||
if (!empty($item['uri-id'])) {
|
||||
$uri_id = $item['uri-id'];
|
||||
$item_id = $item['id'];
|
||||
}
|
||||
} elseif (!empty($uri_id) && !empty($item_id)) {
|
||||
$item = Post::selectFirst(['id'], ['uri-id' => $uri_id, 'uid' => $uid]);
|
||||
if (!empty($item['uri-id'])) {
|
||||
$item_id = $item['id'];
|
||||
}
|
||||
}
|
||||
|
||||
Logger::info('Invoked', ['cmd' => $cmd, 'inbox' => $inbox, 'id' => $item_id, 'uri-id' => $uri_id, 'uid' => $uid]);
|
||||
|
||||
$success = true;
|
||||
@@ -93,7 +80,6 @@ class APDelivery
|
||||
}
|
||||
}
|
||||
|
||||
// This should never fail and is temporariy (until the move to the "post" structure)
|
||||
$gsid = null;
|
||||
|
||||
foreach ($receivers as $receiver) {
|
||||
|
||||
@@ -55,49 +55,33 @@ class Delivery
|
||||
{
|
||||
Logger::info('Invoked', ['cmd' => $cmd, 'target' => $post_uriid, 'sender_uid' => $sender_uid, 'contact' => $contact_id]);
|
||||
|
||||
$target_id = $post_uriid;
|
||||
|
||||
if (!empty($sender_uid)) {
|
||||
$post = Post::selectFirst(['id'], ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
|
||||
if (!DBA::isResult($post)) {
|
||||
Logger::warning('Post not found', ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
|
||||
return;
|
||||
}
|
||||
$target_id = $post['id'];
|
||||
} elseif (!in_array($cmd, [Delivery::MAIL, Delivery::SUGGESTION, Delivery::REMOVAL, Delivery::RELOCATION])) {
|
||||
$post = Post::selectFirst(['id', 'uid', 'uri-id'], ['item-id' => $post_uriid]);
|
||||
if (DBA::isResult($post)) {
|
||||
$target_id = $post['id'];
|
||||
$sender_uid = $post['uid'];
|
||||
$post_uriid = $post['uri-id'];
|
||||
}
|
||||
}
|
||||
|
||||
$top_level = false;
|
||||
$followup = false;
|
||||
$public_message = false;
|
||||
|
||||
$items = [];
|
||||
if ($cmd == self::MAIL) {
|
||||
$target_item = DBA::selectFirst('mail', [], ['id' => $target_id]);
|
||||
$target_item = DBA::selectFirst('mail', [], ['id' => $post_uriid]);
|
||||
if (!DBA::isResult($target_item)) {
|
||||
return;
|
||||
}
|
||||
$uid = $target_item['uid'];
|
||||
} elseif ($cmd == self::SUGGESTION) {
|
||||
$target_item = DBA::selectFirst('fsuggest', [], ['id' => $target_id]);
|
||||
$target_item = DBA::selectFirst('fsuggest', [], ['id' => $post_uriid]);
|
||||
if (!DBA::isResult($target_item)) {
|
||||
return;
|
||||
}
|
||||
$uid = $target_item['uid'];
|
||||
} elseif ($cmd == self::RELOCATION) {
|
||||
$uid = $target_id;
|
||||
$uid = $post_uriid;
|
||||
$target_item = [];
|
||||
} else {
|
||||
$item = Model\Post::selectFirst(['parent'], ['id' => $target_id]);
|
||||
$item = Model\Post::selectFirst(['id', 'parent'], ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
|
||||
if (!DBA::isResult($item) || empty($item['parent'])) {
|
||||
Logger::warning('Post not found', ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
|
||||
return;
|
||||
}
|
||||
$target_id = intval($item['id']);
|
||||
$parent_id = intval($item['parent']);
|
||||
|
||||
$condition = ['id' => [$target_id, $parent_id], 'visible' => true];
|
||||
|
||||
@@ -45,11 +45,11 @@ class Expire
|
||||
Logger::log('Delete expired items', Logger::DEBUG);
|
||||
// physically remove anything that has been deleted for more than two months
|
||||
$condition = ["`deleted` AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY"];
|
||||
$rows = Post::select(['item-id', 'guid', 'uri-id', 'uid'], $condition);
|
||||
$rows = Post::select(['guid', 'uri-id', 'uid'], $condition);
|
||||
while ($row = Post::fetch($rows)) {
|
||||
Logger::info('Delete expired item', ['id' => $row['item-id'], 'guid' => $row['guid']]);
|
||||
Logger::info('Delete expired item', ['uri-id' => $row['uri-id'], 'guid' => $row['guid']]);
|
||||
if (DBStructure::existsTable('item')) {
|
||||
DBA::delete('item', ['id' => $row['item-id']]);
|
||||
DBA::delete('item', ['uri-id' => $row['uri-id'], 'uid' => $row['uid']]);
|
||||
}
|
||||
Post\User::delete(['uri-id' => $row['uri-id'], 'uid' => $row['uid']]);
|
||||
Post\ThreadUser::delete(['uri-id' => $row['uri-id'], 'uid' => $row['uid']]);
|
||||
|
||||
@@ -60,23 +60,6 @@ class Notifier
|
||||
Logger::info('Invoked', ['cmd' => $cmd, 'target' => $post_uriid, 'sender_uid' => $sender_uid]);
|
||||
|
||||
$target_id = $post_uriid;
|
||||
|
||||
if (!empty($sender_uid)) {
|
||||
$post = Post::selectFirst(['id'], ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
|
||||
if (!DBA::isResult($post)) {
|
||||
Logger::warning('Post not found', ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
|
||||
return;
|
||||
}
|
||||
$target_id = $post['id'];
|
||||
} elseif (!in_array($cmd, [Delivery::MAIL, Delivery::SUGGESTION, Delivery::REMOVAL, Delivery::RELOCATION])) {
|
||||
$post = Post::selectFirst(['id', 'uid', 'uri-id'], ['item-id' => $post_uriid]);
|
||||
if (DBA::isResult($post)) {
|
||||
$target_id = $post['id'];
|
||||
$sender_uid = $post['uid'];
|
||||
$post_uriid = $post['uri-id'];
|
||||
}
|
||||
}
|
||||
|
||||
$top_level = false;
|
||||
$recipients = [];
|
||||
$url_recipients = [];
|
||||
@@ -117,6 +100,13 @@ class Notifier
|
||||
$condition = ['uid' => $target_id, 'self' => false, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
|
||||
$delivery_contacts_stmt = DBA::select('contact', ['id', 'url', 'addr', 'network', 'protocol', 'batch'], $condition);
|
||||
} else {
|
||||
$post = Post::selectFirst(['id'], ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
|
||||
if (!DBA::isResult($post)) {
|
||||
Logger::warning('Post not found', ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
|
||||
return;
|
||||
}
|
||||
$target_id = $post['id'];
|
||||
|
||||
// find ancestors
|
||||
$condition = ['id' => $target_id, 'visible' => true];
|
||||
$target_item = Post::selectFirst(Item::DELIVER_FIELDLIST, $condition);
|
||||
|
||||
@@ -53,10 +53,10 @@ class RemoveContact {
|
||||
}
|
||||
if (DBStructure::existsTable('item')) {
|
||||
do {
|
||||
$items = Post::select(['item-id', 'post-user-id', 'uri-id', 'guid'], $condition, ['limit' => 100]);
|
||||
$items = Post::select(['uri-id', 'guid', 'uid'], $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']]);
|
||||
Logger::info('Delete removed contact item', ['uri-id' => $item['uri-id'], 'uid', 'guid' => $item['guid']]);
|
||||
DBA::delete('item', ['uri-id' => $item['uri-id'], 'uid' => $item['uid']]);
|
||||
}
|
||||
DBA::close($items);
|
||||
} while (Post::exists($condition));
|
||||
|
||||
Reference in New Issue
Block a user