mirror of
https://github.com/friendica/friendica
synced 2024-12-22 23:20:16 +00:00
Post expiry: Limit for deletions
This commit is contained in:
parent
a28930f174
commit
5a685427ac
2 changed files with 37 additions and 23 deletions
|
@ -39,7 +39,13 @@ class ExpirePosts
|
|||
$expire_days_unclaimed = $expire_days;
|
||||
}
|
||||
|
||||
$limit = DI::config()->get('system', 'dbclean-expire-limit');
|
||||
if (empty($limit)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($expire_days)) {
|
||||
do {
|
||||
Logger::notice('Start deleting expired threads', ['expiry_days' => $expire_days]);
|
||||
$ret = DBA::e("DELETE FROM `item-uri` WHERE `id` IN
|
||||
(SELECT `uri-id` FROM `thread`
|
||||
|
@ -52,22 +58,29 @@ class ExpirePosts
|
|||
OR `item`.`wall` OR `item`.`origin`
|
||||
OR `uri-id` IN (SELECT `uri-id` FROM `post-category`
|
||||
WHERE `uri-id` = `item`.`uri-id`))
|
||||
AND `item`.`parent` = `thread`.`iid`))", $expire_days);
|
||||
AND `item`.`parent` = `thread`.`iid`))
|
||||
ORDER BY `id` LIMIT ?", $expire_days, $limit);
|
||||
|
||||
Logger::notice('Deleted expired threads', ['result' => $ret, 'rows' => DBA::affectedRows()]);
|
||||
$rows = DBA::affectedRows();
|
||||
Logger::notice('Deleted expired threads', ['result' => $ret, 'rows' => $rows]);
|
||||
} while ($rows >= $limit);
|
||||
}
|
||||
|
||||
if (!empty($expire_days_unclaimed)) {
|
||||
$expiry_date = DateTimeFormat::utc('now - ' . $expire_days_unclaimed . ' days', DateTimeFormat::MYSQL);
|
||||
|
||||
do {
|
||||
Logger::notice('Start deleting unclaimed public items', ['expiry_days' => $expire_days_unclaimed, 'expired' => $expiry_date]);
|
||||
$ret = DBA::e("DELETE FROM `item-uri` WHERE `id` IN
|
||||
(SELECT `uri-id` FROM `item` WHERE `gravity` = ? AND `uid` = ? AND `received` < ?
|
||||
AND NOT `uri-id` IN (SELECT `parent-uri-id` FROM `item` WHERE `uid` != ?)
|
||||
AND NOT `uri-id` IN (SELECT `parent-uri-id` FROM `item` WHERE `uid` = ? AND `received` > ?))",
|
||||
GRAVITY_PARENT, 0, $expiry_date, 0, 0, $expiry_date);
|
||||
AND NOT `uri-id` IN (SELECT `parent-uri-id` FROM `item` WHERE `uid` = ? AND `received` > ?))
|
||||
ORDER BY `id` LIMIT ?",
|
||||
GRAVITY_PARENT, 0, $expiry_date, 0, 0, $expiry_date, $limit);
|
||||
|
||||
Logger::notice('Deleted unclaimed public items', ['result' => $ret, 'rows' => DBA::affectedRows()]);
|
||||
$rows = DBA::affectedRows();
|
||||
Logger::notice('Deleted unclaimed public items', ['result' => $ret, 'rows' => $rows]);
|
||||
} while ($rows >= $limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,7 +187,8 @@ return [
|
|||
|
||||
// dbclean-expire-limit (Integer)
|
||||
// This defines the number of items that are to be deleted in a single call.
|
||||
// Reduce this value when you are getting memory issues.
|
||||
// Reduce this value when you are getting lock issues.
|
||||
// A value of 0 disables the deletion process.
|
||||
'dbclean-expire-limit' => 1000,
|
||||
|
||||
// diaspora_test (Boolean)
|
||||
|
|
Loading…
Reference in a new issue