We now don't store in the "item" table anymore
This commit is contained in:
@@ -1042,38 +1042,13 @@ class Item
|
||||
Post\ThreadUser::insert($item['uri-id'], $item['uid'], $item);
|
||||
}
|
||||
|
||||
// Remove all fields that aren't part of the item table
|
||||
$table_fields = DBStructure::getFieldsForTable('item', $item);
|
||||
|
||||
// We remove all legacy fields that now are stored in other tables
|
||||
foreach (self::LEGACY_FIELDLIST as $field) {
|
||||
unset($table_fields[$field]);
|
||||
}
|
||||
|
||||
$result = DBA::insert('item', $table_fields);
|
||||
|
||||
// When the item was successfully stored we fetch the ID of the item.
|
||||
$current_post = DBA::lastInsertId();
|
||||
|
||||
if (empty($current_post) || !DBA::isResult($result)) {
|
||||
// On failure store the data into a spool file so that the "SpoolPost" worker can try again later.
|
||||
Logger::warning('Could not store item. it will be spooled', ['result' => $result, 'id' => $current_post]);
|
||||
self::spool($orig_item);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Logger::notice('created item', ['id' => $current_post, 'uid' => $item['uid'], 'network' => $item['network'], 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
|
||||
|
||||
if (!$parent_id || ($item['gravity'] === GRAVITY_PARENT)) {
|
||||
$parent_id = $current_post;
|
||||
}
|
||||
|
||||
// Set parent id
|
||||
DBA::update('item', ['parent' => $parent_id], ['id' => $current_post]);
|
||||
Logger::notice('created item', ['post-id' => $post_user_id, 'uid' => $item['uid'], 'network' => $item['network'], 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
|
||||
|
||||
$posted_item = Post::selectFirst(self::ITEM_FIELDLIST, ['post-user-id' => $post_user_id]);
|
||||
if (!DBA::isResult($posted_item)) {
|
||||
Logger::warning('new item not found in DB', ['id' => $post_user_id]);
|
||||
// On failure store the data into a spool file so that the "SpoolPost" worker can try again later.
|
||||
Logger::warning('Could not store item. it will be spooled', ['id' => $post_user_id]);
|
||||
self::spool($orig_item);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1164,15 +1139,15 @@ class Item
|
||||
return;
|
||||
}
|
||||
|
||||
$author = Contact::selectFirst(['url', 'contact-type'], ['id' => $item['author-id']]);
|
||||
$author = Contact::selectFirst(['url', 'contact-type', 'network'], ['id' => $item['author-id']]);
|
||||
if (!DBA::isResult($author)) {
|
||||
Logger::error('Author not found', ['id' => $item['author-id']]);
|
||||
return;
|
||||
}
|
||||
|
||||
$cid = Contact::getIdForURL($author['url'], $item['uid']);
|
||||
if (empty($cid) || !Contact::isSharing($cid, $item['uid'])) {
|
||||
Logger::info('The resharer is not a following contact: quit', ['resharer' => $author['url'], 'uid' => $item['uid']]);
|
||||
if (empty($cid) || (!Contact::isSharing($cid, $item['uid'] && in_array($author['network'], Protocol::FEDERATED)))) {
|
||||
Logger::info('The resharer is not a following contact: quit', ['resharer' => $author['url'], 'uid' => $item['uid'], 'cid' => $cid]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1815,7 +1790,6 @@ class Item
|
||||
if (($community_page || $prvgroup) &&
|
||||
!$item['wall'] && !$item['origin'] && ($item['gravity'] == GRAVITY_PARENT)) {
|
||||
Logger::info('Delete private group/communiy top-level item without mention', ['id' => $item['id'], 'guid'=> $item['guid']]);
|
||||
DBA::delete('item', ['uri-id' => $item['uri-id'], 'uid' => $item['uid']]);
|
||||
Post\User::delete(['uri-id' => $item['uri-id'], 'uid' => $item['uid']]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace Friendica\Model;
|
||||
|
||||
use BadMethodCallException;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBStructure;
|
||||
@@ -516,23 +515,6 @@ class Post
|
||||
$affected = max($affected, DBA::affectedRows());
|
||||
}
|
||||
|
||||
$update_fields = [];
|
||||
foreach (Item::USED_FIELDLIST as $field) {
|
||||
if (array_key_exists($field, $fields)) {
|
||||
$update_fields[$field] = $fields[$field];
|
||||
}
|
||||
}
|
||||
if (!empty($update_fields)) {
|
||||
$rows = DBA::selectToArray('post-view', ['item-id'], $condition, []);
|
||||
$ids = array_column($rows, 'item-id');
|
||||
if (!DBA::update('item', $update_fields, ['id' => $ids])) {
|
||||
DBA::rollback();
|
||||
Logger::notice('Updating item failed', ['fields' => $update_fields, 'condition' => $condition]);
|
||||
return false;
|
||||
}
|
||||
$affected = max($affected, DBA::affectedRows());
|
||||
}
|
||||
|
||||
DBA::commit();
|
||||
|
||||
Logger::info('Updated posts', ['rows' => $affected]);
|
||||
|
||||
@@ -25,6 +25,7 @@ use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
@@ -47,7 +48,9 @@ class Expire
|
||||
$rows = Post::select(['item-id', 'guid', 'uri-id', 'uid'], $condition);
|
||||
while ($row = Post::fetch($rows)) {
|
||||
Logger::info('Delete expired item', ['id' => $row['item-id'], 'guid' => $row['guid']]);
|
||||
DBA::delete('item', ['id' => $row['item-id']]);
|
||||
if (DBStructure::existsTable('item')) {
|
||||
DBA::delete('item', ['id' => $row['item-id']]);
|
||||
}
|
||||
Post\User::delete(['uri-id' => $row['uri-id'], 'uid' => $row['uid']]);
|
||||
Post\ThreadUser::delete(['uri-id' => $row['uri-id'], 'uid' => $row['uid']]);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Model\User;
|
||||
|
||||
@@ -64,7 +65,9 @@ class ExpireAndRemoveUsers
|
||||
// It seems that sometimes the system wants to delete the records in the wrong order.
|
||||
// So when the permissionset is deleted and these tables are still filled then an error is thrown.
|
||||
// So we now delete them before all other user related entries are deleted.
|
||||
DBA::delete('item', ['uid' => $user['uid']]);
|
||||
if (DBStructure::existsTable('item')) {
|
||||
DBA::delete('item', ['uid' => $user['uid']]);
|
||||
}
|
||||
DBA::delete('post-user', ['uid' => $user['uid']]);
|
||||
DBA::delete('profile_field', ['uid' => $user['uid']]);
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Model\Post;
|
||||
|
||||
@@ -50,7 +51,9 @@ class RemoveContact {
|
||||
$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']]);
|
||||
if (DBStructure::existsTable('item')) {
|
||||
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']]);
|
||||
|
||||
Reference in New Issue
Block a user