mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-08 08:14:25 +02:00
"item" is replaced whenever possible at the moment
This commit is contained in:
parent
0fe37b123a
commit
8f27715d8b
9 changed files with 21 additions and 21 deletions
|
@ -23,6 +23,7 @@ namespace Friendica\Worker;
|
|||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Post;
|
||||
|
||||
class CleanItemUri
|
||||
{
|
||||
|
@ -33,7 +34,7 @@ class CleanItemUri
|
|||
{
|
||||
// We have to avoid deleting newly created "item-uri" entries.
|
||||
// So we fetch a post that had been stored yesterday and only delete older ones.
|
||||
$item = DBA::selectFirst('item', ['uri-id'], ["`uid` = ? AND `received` < UTC_TIMESTAMP() - INTERVAL ? DAY", 0, 1],
|
||||
$item = Post::selectFirst(['uri-id'], ["`uid` = ? AND `received` < UTC_TIMESTAMP() - INTERVAL ? DAY", 0, 1],
|
||||
['order' => ['received' => true]]);
|
||||
if (empty($item['uri-id'])) {
|
||||
Logger::warning('No item with uri-id found - we better quit here');
|
||||
|
|
|
@ -44,11 +44,12 @@ 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 = DBA::select('item', ['id', 'guid', 'uri-id', 'uid'], $condition);
|
||||
while ($row = DBA::fetch($rows)) {
|
||||
$rows = Post::select(['id', 'guid', 'uri-id', 'uid'], $condition);
|
||||
while ($row = Post::fetch($rows)) {
|
||||
Logger::info('Delete expired item', ['id' => $row['id'], 'guid' => $row['guid']]);
|
||||
DBA::delete('item', ['id' => $row['id']]);
|
||||
Post\User::delete(['uri-id' => $row['uri-id'], 'uid' => $row['uid']]);
|
||||
Post\ThreadUser::delete(['uri-id' => $row['uri-id'], 'uid' => $row['uid']]);
|
||||
}
|
||||
DBA::close($rows);
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace Friendica\Worker;
|
|||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Post;
|
||||
|
||||
class MergeContact
|
||||
{
|
||||
|
@ -43,8 +44,7 @@ class MergeContact
|
|||
Logger::info('Handling duplicate', ['search' => $old_cid, 'replace' => $new_cid]);
|
||||
|
||||
// Search and replace
|
||||
DBA::update('item', ['contact-id' => $new_cid], ['contact-id' => $old_cid]);
|
||||
DBA::update('thread', ['contact-id' => $new_cid], ['contact-id' => $old_cid]);
|
||||
Post::update(['contact-id' => $new_cid], ['contact-id' => $old_cid]);
|
||||
DBA::update('mail', ['contact-id' => $new_cid], ['contact-id' => $old_cid]);
|
||||
DBA::update('photo', ['contact-id' => $new_cid], ['contact-id' => $old_cid]);
|
||||
DBA::update('event', ['cid' => $new_cid], ['cid' => $old_cid]);
|
||||
|
@ -53,11 +53,9 @@ class MergeContact
|
|||
if ($uid == 0) {
|
||||
DBA::update('post-tag', ['cid' => $new_cid], ['cid' => $old_cid]);
|
||||
DBA::delete('post-tag', ['cid' => $old_cid]);
|
||||
DBA::update('item', ['author-id' => $new_cid], ['author-id' => $old_cid]);
|
||||
DBA::update('item', ['owner-id' => $new_cid], ['owner-id' => $old_cid]);
|
||||
DBA::update('item', ['causer-id' => $new_cid], ['causer-id' => $old_cid]);
|
||||
DBA::update('thread', ['author-id' => $new_cid], ['author-id' => $old_cid]);
|
||||
DBA::update('thread', ['owner-id' => $new_cid], ['owner-id' => $old_cid]);
|
||||
Post::update(['author-id' => $new_cid], ['author-id' => $old_cid]);
|
||||
Post::update(['owner-id' => $new_cid], ['owner-id' => $old_cid]);
|
||||
Post::update(['causer-id' => $new_cid], ['causer-id' => $old_cid]);
|
||||
} else {
|
||||
/// @todo Check if some other data needs to be adjusted as well, possibly the "rel" status?
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ use Friendica\Model\ItemURI;
|
|||
|
||||
/**
|
||||
* Do some repairs in database entries
|
||||
*
|
||||
* @todo This class can be deleted without replacement when the item table is removed
|
||||
*/
|
||||
class RepairDatabase
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue