]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/DBClean.php
Update does work now
[friendica.git] / src / Worker / DBClean.php
index ffb24af09e9dc6bf60d5e8479124dfdba82d41ad..deb23e8dd8c901e7a9f0b83298b894776026623b 100644 (file)
@@ -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);