mirror of
https://github.com/friendica/friendica
synced 2024-11-18 00:23:47 +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;
|
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)) {
|
if (!$uid || ($days < 1)) {
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$condition = [
|
$condition = [
|
||||||
|
@ -2913,7 +2913,7 @@ class Item
|
||||||
$items = Post::select(['resource-id', 'starred', 'id', 'post-type', 'uid', 'uri-id'], $condition);
|
$items = Post::select(['resource-id', 'starred', 'id', 'post-type', 'uid', 'uri-id'], $condition);
|
||||||
|
|
||||||
if (!DBA::isResult($items)) {
|
if (!DBA::isResult($items)) {
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$expire_items = (bool)DI::pConfig()->get($uid, 'expire', 'items', true);
|
$expire_items = (bool)DI::pConfig()->get($uid, 'expire', 'items', true);
|
||||||
|
@ -2955,6 +2955,7 @@ class Item
|
||||||
}
|
}
|
||||||
DBA::close($items);
|
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]);
|
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)
|
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, 'ExpireSearchIndex');
|
||||||
|
|
||||||
|
Worker::add(Worker::PRIORITY_LOW, 'Expire');
|
||||||
|
|
||||||
Worker::add(Worker::PRIORITY_LOW, 'RemoveUnusedTags');
|
Worker::add(Worker::PRIORITY_LOW, 'RemoveUnusedTags');
|
||||||
|
|
||||||
Worker::add(Worker::PRIORITY_LOW, 'RemoveUnusedContacts');
|
Worker::add(Worker::PRIORITY_LOW, 'RemoveUnusedContacts');
|
||||||
|
|
||||||
Worker::add(Worker::PRIORITY_LOW, 'RemoveUnusedAvatars');
|
Worker::add(Worker::PRIORITY_LOW, 'RemoveUnusedAvatars');
|
||||||
|
|
||||||
|
Worker::add(Worker::PRIORITY_LOW, 'NodeInfo');
|
||||||
|
|
||||||
// check upstream version?
|
// check upstream version?
|
||||||
Worker::add(Worker::PRIORITY_LOW, 'CheckVersion');
|
Worker::add(Worker::PRIORITY_LOW, 'CheckVersion');
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ class Expire
|
||||||
$user = DBA::selectFirst('user', ['uid', 'username', 'expire'], ['uid' => $param]);
|
$user = DBA::selectFirst('user', ['uid', 'username', 'expire'], ['uid' => $param]);
|
||||||
if (DBA::isResult($user)) {
|
if (DBA::isResult($user)) {
|
||||||
Logger::info('Expire items', ['user' => $user['uid'], 'username' => $user['username'], 'interval' => $user['expire']]);
|
Logger::info('Expire items', ['user' => $user['uid'], 'username' => $user['username'], 'interval' => $user['expire']]);
|
||||||
Item::expire($user['uid'], $user['expire']);
|
$expired = Item::expire($user['uid'], $user['expire']);
|
||||||
Logger::info('Expire items done', ['user' => $user['uid'], 'username' => $user['username'], 'interval' => $user['expire']]);
|
Logger::info('Expire items done', ['user' => $user['uid'], 'username' => $user['username'], 'interval' => $user['expire'], 'expired' => $expired]);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} elseif ($param == 'hook' && !empty($hook_function)) {
|
} elseif ($param == 'hook' && !empty($hook_function)) {
|
||||||
|
|
|
@ -27,32 +27,36 @@ class ExpirePosts
|
||||||
*/
|
*/
|
||||||
public static function execute()
|
public static function execute()
|
||||||
{
|
{
|
||||||
|
Logger::notice('Expire posts - start');
|
||||||
|
|
||||||
if (!DBA::acquireOptimizeLock()) {
|
if (!DBA::acquireOptimizeLock()) {
|
||||||
Logger::warning('Lock could not be acquired');
|
Logger::warning('Lock could not be acquired');
|
||||||
|
Worker::defer();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger::notice('Expire posts - Delete expired origin posts');
|
||||||
self::deleteExpiredOriginPosts();
|
self::deleteExpiredOriginPosts();
|
||||||
|
|
||||||
|
Logger::notice('Expire posts - Delete orphaned entries');
|
||||||
self::deleteOrphanedEntries();
|
self::deleteOrphanedEntries();
|
||||||
|
|
||||||
|
Logger::notice('Expire posts - delete unused item-uri entries');
|
||||||
self::deleteUnusedItemUri();
|
self::deleteUnusedItemUri();
|
||||||
|
|
||||||
|
Logger::notice('Expire posts - delete external posts');
|
||||||
self::deleteExpiredExternalPosts();
|
self::deleteExpiredExternalPosts();
|
||||||
|
|
||||||
if (DI::config()->get('system', 'add_missing_posts')) {
|
if (DI::config()->get('system', 'add_missing_posts')) {
|
||||||
|
Logger::notice('Expire posts - add missing posts');
|
||||||
self::addMissingEntries();
|
self::addMissingEntries();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger::notice('Expire posts - delete unused attachments');
|
||||||
self::deleteUnusedAttachments();
|
self::deleteUnusedAttachments();
|
||||||
|
|
||||||
DBA::releaseOptimizeLock();
|
DBA::releaseOptimizeLock();
|
||||||
|
Logger::notice('Expire posts - done');
|
||||||
// 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');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue