<?php
/**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
namespace Friendica\Worker;
+use Friendica\Contact\Avatar;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Database\DBA;
{
$condition = ["`id` != ? AND `uid` = ? AND NOT `self` AND NOT `nurl` IN (SELECT `nurl` FROM `contact` WHERE `uid` != ?)
AND (NOT `network` IN (?, ?, ?, ?, ?, ?) OR (`archive` AND `success_update` < ?))
- AND NOT `id` IN (SELECT `author-id` FROM `post-user`) AND NOT `id` IN (SELECT `owner-id` FROM `post-user`)
- AND NOT `id` IN (SELECT `causer-id` FROM `post-user`) AND NOT `id` IN (SELECT `cid` FROM `post-tag`)
- AND NOT `id` IN (SELECT `contact-id` FROM `post-user`) AND NOT `id` IN (SELECT `cid` FROM `user-contact`)
- AND NOT `id` IN (SELECT `cid` FROM `event`) AND NOT `id` IN (SELECT `contact-id` FROM `group_member`)
+ AND NOT `id` IN (SELECT `author-id` FROM `post-user` WHERE `author-id` = `contact`.`id`)
+ AND NOT `id` IN (SELECT `owner-id` FROM `post-user` WHERE `owner-id` = `contact`.`id`)
+ AND NOT `id` IN (SELECT `causer-id` FROM `post-user` WHERE `causer-id` IS NOT NULL AND `causer-id` = `contact`.`id`)
+ AND NOT `id` IN (SELECT `cid` FROM `post-tag` WHERE `cid` = `contact`.`id`)
+ AND NOT `id` IN (SELECT `contact-id` FROM `post-user` WHERE `contact-id` = `contact`.`id`)
+ AND NOT `id` IN (SELECT `cid` FROM `user-contact` WHERE `cid` = `contact`.`id`)
+ AND NOT `id` IN (SELECT `cid` FROM `event` WHERE `cid` = `contact`.`id`)
+ AND NOT `id` IN (SELECT `contact-id` FROM `group_member` WHERE `contact-id` = `contact`.`id`)
AND `created` < ?",
0, 0, 0, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL, Protocol::ACTIVITYPUB, DateTimeFormat::utc('now - 365 days'), DateTimeFormat::utc('now - 30 days')];
$contacts = DBA::select('contact', ['id', 'uid', 'photo', 'thumb', 'micro'], $condition);
while ($contact = DBA::fetch($contacts)) {
Photo::delete(['uid' => $contact['uid'], 'contact-id' => $contact['id']]);
- Contact::deleteAvatarCache($contact['photo']);
- Contact::deleteAvatarCache($contact['thumb']);
- Contact::deleteAvatarCache($contact['micro']);
+ Avatar::deleteCache($contact);
if (DBStructure::existsTable('thread')) {
DBA::delete('thread', ['owner-id' => $contact['id']]);
DBA::delete('post', ['owner-id' => $contact['id']]);
DBA::delete('post', ['author-id' => $contact['id']]);
DBA::delete('post', ['causer-id' => $contact['id']]);
-
+
DBA::delete('post-thread', ['owner-id' => $contact['id']]);
DBA::delete('post-thread', ['author-id' => $contact['id']]);
DBA::delete('post-thread', ['causer-id' => $contact['id']]);
DBA::delete('post-thread-user', ['author-id' => $contact['id']]);
DBA::delete('post-thread-user', ['causer-id' => $contact['id']]);
- DBA::delete('contact', ['id' => $contact['id']]);
+ Contact::deleteById($contact['id']);
if ((++$count % 1000) == 0) {
- Logger::notice('In removal', ['count' => $count, 'total' => $total]);
+ Logger::info('In removal', ['count' => $count, 'total' => $total]);
}
}
DBA::close($contacts);