X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWorker%2FDBClean.php;h=deb23e8dd8c901e7a9f0b83298b894776026623b;hb=f33bd5fc8e5d3cf9462869815e6c68df6fbfa039;hp=ffb24af09e9dc6bf60d5e8479124dfdba82d41ad;hpb=26b335ef3d8b1ec4e1b4e22cd7d3c34e66d2549d;p=friendica.git diff --git a/src/Worker/DBClean.php b/src/Worker/DBClean.php index ffb24af09e..deb23e8dd8 100644 --- a/src/Worker/DBClean.php +++ b/src/Worker/DBClean.php @@ -69,15 +69,24 @@ class DBClean { // Get the expire days for step 8 and 9 $days = Config::get('system', 'dbclean-expire-days', 0); + $days_unclaimed = Config::get('system', 'dbclean-expire-unclaimed', 90); + + if ($days_unclaimed == 0) { + $days_unclaimed = $days; + } if ($stage == 1) { + if ($days_unclaimed <= 0) { + return; + } + $last_id = Config::get('system', 'dbclean-last-id-1', 0); logger("Deleting old global item entries from item table without user copy. Last ID: ".$last_id); $r = dba::p("SELECT `id` FROM `item` WHERE `uid` = 0 AND NOT EXISTS (SELECT `guid` FROM `item` AS `i` WHERE `item`.`guid` = `i`.`guid` AND `i`.`uid` != 0) AND - `received` < UTC_TIMESTAMP() - INTERVAL 90 DAY AND `id` >= ? - ORDER BY `id` LIMIT ".intval($limit), $last_id); + `received` < UTC_TIMESTAMP() - INTERVAL ? DAY AND `id` >= ? + ORDER BY `id` LIMIT ".intval($limit), $days_unclaimed, $last_id); $count = dba::num_rows($r); if ($count > 0) { logger("found global item orphans: ".$count); @@ -314,11 +323,12 @@ class DBClean { Config::set('system', 'dbclean-last-id-9', $last_id); } elseif ($stage == 10) { $last_id = Config::get('system', 'dbclean-last-id-10', 0); + $days = intval(Config::get('system', 'dbclean_expire_conversation', 90)); logger("Deleting old conversations. Last created: ".$last_id); $r = dba::p("SELECT `received`, `item-uri` FROM `conversation` - WHERE `received` < UTC_TIMESTAMP() - INTERVAL 90 DAY - ORDER BY `received` LIMIT ".intval($limit)); + WHERE `received` < UTC_TIMESTAMP() - INTERVAL ? DAY + ORDER BY `received` LIMIT ".intval($limit), $days); $count = dba::num_rows($r); if ($count > 0) { logger("found old conversations: ".$count);