mirror of
https://github.com/friendica/friendica
synced 2024-11-17 22:23:41 +00:00
Issue 14413: Ensure that the expiry is performed
This commit is contained in:
parent
9bf5b27362
commit
9bdf7d806b
4 changed files with 20 additions and 11 deletions
|
@ -2881,10 +2881,10 @@ class Item
|
|||
return $recipients;
|
||||
}
|
||||
|
||||
public static function expire(int $uid, int $days, string $network = "", bool $force = false)
|
||||
public static function expire(int $uid, int $days, string $network = "", bool $force = false): int
|
||||
{
|
||||
if (!$uid || ($days < 1)) {
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
$condition = [
|
||||
|
@ -2913,7 +2913,7 @@ class Item
|
|||
$items = Post::select(['resource-id', 'starred', 'id', 'post-type', 'uid', 'uri-id'], $condition);
|
||||
|
||||
if (!DBA::isResult($items)) {
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
$expire_items = (bool)DI::pConfig()->get($uid, 'expire', 'items', true);
|
||||
|
@ -2955,6 +2955,7 @@ class Item
|
|||
}
|
||||
DBA::close($items);
|
||||
Logger::notice('Expired', ['user' => $uid, 'days' => $days, 'network' => $network, 'force' => $force, 'expired' => $expired, 'expire items' => $expire_items, 'expire notes' => $expire_notes, 'expire starred' => $expire_starred, 'expire photos' => $expire_photos, 'condition' => $condition]);
|
||||
return $expired;
|
||||
}
|
||||
|
||||
public static function firstPostDate(int $uid, bool $wall = false)
|
||||
|
|
|
@ -107,12 +107,16 @@ class Cron
|
|||
|
||||
Worker::add(Worker::PRIORITY_LOW, 'ExpireSearchIndex');
|
||||
|
||||
Worker::add(Worker::PRIORITY_LOW, 'Expire');
|
||||
|
||||
Worker::add(Worker::PRIORITY_LOW, 'RemoveUnusedTags');
|
||||
|
||||
Worker::add(Worker::PRIORITY_LOW, 'RemoveUnusedContacts');
|
||||
|
||||
Worker::add(Worker::PRIORITY_LOW, 'RemoveUnusedAvatars');
|
||||
|
||||
Worker::add(Worker::PRIORITY_LOW, 'NodeInfo');
|
||||
|
||||
// check upstream version?
|
||||
Worker::add(Worker::PRIORITY_LOW, 'CheckVersion');
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ class Expire
|
|||
$user = DBA::selectFirst('user', ['uid', 'username', 'expire'], ['uid' => $param]);
|
||||
if (DBA::isResult($user)) {
|
||||
Logger::info('Expire items', ['user' => $user['uid'], 'username' => $user['username'], 'interval' => $user['expire']]);
|
||||
Item::expire($user['uid'], $user['expire']);
|
||||
Logger::info('Expire items done', ['user' => $user['uid'], 'username' => $user['username'], 'interval' => $user['expire']]);
|
||||
$expired = Item::expire($user['uid'], $user['expire']);
|
||||
Logger::info('Expire items done', ['user' => $user['uid'], 'username' => $user['username'], 'interval' => $user['expire'], 'expired' => $expired]);
|
||||
}
|
||||
return;
|
||||
} elseif ($param == 'hook' && !empty($hook_function)) {
|
||||
|
|
|
@ -27,32 +27,36 @@ class ExpirePosts
|
|||
*/
|
||||
public static function execute()
|
||||
{
|
||||
Logger::notice('Expire posts - start');
|
||||
|
||||
if (!DBA::acquireOptimizeLock()) {
|
||||
Logger::warning('Lock could not be acquired');
|
||||
Worker::defer();
|
||||
return;
|
||||
}
|
||||
|
||||
Logger::notice('Expire posts - Delete expired origin posts');
|
||||
self::deleteExpiredOriginPosts();
|
||||
|
||||
Logger::notice('Expire posts - Delete orphaned entries');
|
||||
self::deleteOrphanedEntries();
|
||||
|
||||
Logger::notice('Expire posts - delete unused item-uri entries');
|
||||
self::deleteUnusedItemUri();
|
||||
|
||||
Logger::notice('Expire posts - delete external posts');
|
||||
self::deleteExpiredExternalPosts();
|
||||
|
||||
if (DI::config()->get('system', 'add_missing_posts')) {
|
||||
Logger::notice('Expire posts - add missing posts');
|
||||
self::addMissingEntries();
|
||||
}
|
||||
|
||||
Logger::notice('Expire posts - delete unused attachments');
|
||||
self::deleteUnusedAttachments();
|
||||
|
||||
DBA::releaseOptimizeLock();
|
||||
|
||||
// Set the expiry for origin posts
|
||||
Worker::add(Worker::PRIORITY_LOW, 'Expire');
|
||||
|
||||
// update nodeinfo data after everything is cleaned up
|
||||
Worker::add(Worker::PRIORITY_LOW, 'NodeInfo');
|
||||
Logger::notice('Expire posts - done');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue