]> git.mxchange.org Git - friendica.git/commitdiff
run dbclean as long as there is some data to be purged
authorMichael <heluecht@pirati.ca>
Tue, 1 Nov 2016 21:36:15 +0000 (21:36 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 1 Nov 2016 21:36:15 +0000 (21:36 +0000)
include/cron.php
include/dbclean.php

index 5b588fee6f3499a8faada66496f7dd9dc2eaa8f2..925bb5eab5c26a9f3d2a525af8cbd15f65185d43 100644 (file)
@@ -126,17 +126,7 @@ function cron_run(&$argv, &$argc){
 
                proc_run(PRIORITY_LOW, 'include/expire.php');
 
-               if (get_config("system", "worker")) {
-                       proc_run(PRIORITY_LOW, 'include/dbclean.php', 1);
-                       proc_run(PRIORITY_LOW, 'include/dbclean.php', 2);
-                       proc_run(PRIORITY_LOW, 'include/dbclean.php', 3);
-                       proc_run(PRIORITY_LOW, 'include/dbclean.php', 4);
-                       proc_run(PRIORITY_LOW, 'include/dbclean.php', 5);
-                       proc_run(PRIORITY_LOW, 'include/dbclean.php', 6);
-                       proc_run(PRIORITY_LOW, 'include/dbclean.php', 7);
-               } else {
-                       proc_run(PRIORITY_LOW, 'include/dbclean.php');
-               }
+               proc_run(PRIORITY_LOW, 'include/dbclean.php');
 
                cron_update_photo_albums();
        }
index 22a6d4e4297b4ad3675048e3bf6df717118018c7..0baece81685678fa7bcbff4978ad1eaafed21704 100644 (file)
@@ -26,7 +26,18 @@ function dbclean_run(&$argv, &$argc) {
        } else {
                $stage = 0;
        }
-       remove_orphans($stage);
+
+       if (get_config("system", "worker") AND ($stage == 0)) {
+               proc_run(PRIORITY_LOW, 'include/dbclean.php', 1);
+               proc_run(PRIORITY_LOW, 'include/dbclean.php', 2);
+               proc_run(PRIORITY_LOW, 'include/dbclean.php', 3);
+               proc_run(PRIORITY_LOW, 'include/dbclean.php', 4);
+               proc_run(PRIORITY_LOW, 'include/dbclean.php', 5);
+               proc_run(PRIORITY_LOW, 'include/dbclean.php', 6);
+               proc_run(PRIORITY_LOW, 'include/dbclean.php', 7);
+       } else {
+               remove_orphans($stage);
+       }
 }
 
 /**
@@ -35,6 +46,8 @@ function dbclean_run(&$argv, &$argc) {
 function remove_orphans($stage = 0) {
        global $db;
 
+       $count = 0;
+
        if (($stage == 1) OR ($stage == 0)) {
                logger("Deleting old global item entries from item table without user copy");
                if ($db->q("SELECT `id` FROM `item` WHERE `uid` = 0
@@ -45,11 +58,6 @@ function remove_orphans($stage = 0) {
                        while ($orphan = $db->qfetch()) {
                                q("DELETE FROM `item` WHERE `id` = %d", intval($orphan["id"]));
                        }
-
-                       // Call it again if not all entries were purged
-                       if (($count > 0) AND get_config("system", "worker")) {
-                               proc_run(PRIORITY_LOW, 'include/dbclean.php', 1);
-                       }
                }
                $db->qclose();
                logger("Done deleting old global item entries from item table without user copy");
@@ -63,11 +71,6 @@ function remove_orphans($stage = 0) {
                        while ($orphan = $db->qfetch()) {
                                q("DELETE FROM `item` WHERE `id` = %d", intval($orphan["id"]));
                        }
-
-                       // Call it again if not all entries were purged
-                       if (($count > 0) AND get_config("system", "worker")) {
-                               proc_run(PRIORITY_LOW, 'include/dbclean.php', 2);
-                       }
                }
                $db->qclose();
                logger("Done deleting items without parents");
@@ -81,11 +84,6 @@ function remove_orphans($stage = 0) {
                        while ($orphan = $db->qfetch()) {
                                q("DELETE FROM `thread` WHERE `iid` = %d", intval($orphan["iid"]));
                        }
-
-                       // Call it again if not all entries were purged
-                       if (($count > 0) AND get_config("system", "worker")) {
-                               proc_run(PRIORITY_LOW, 'include/dbclean.php', 3);
-                       }
                }
                $db->qclose();
                logger("Done deleting orphaned data from thread table");
@@ -99,11 +97,6 @@ function remove_orphans($stage = 0) {
                        while ($orphan = $db->qfetch()) {
                                q("DELETE FROM `notify` WHERE `iid` = %d", intval($orphan["iid"]));
                        }
-
-                       // Call it again if not all entries were purged
-                       if (($count > 0) AND get_config("system", "worker")) {
-                               proc_run(PRIORITY_LOW, 'include/dbclean.php', 4);
-                       }
                }
                $db->qclose();
                logger("Done deleting orphaned data from notify table");
@@ -117,11 +110,6 @@ function remove_orphans($stage = 0) {
                        while ($orphan = $db->qfetch()) {
                                q("DELETE FROM `notify-threads` WHERE `id` = %d", intval($orphan["id"]));
                        }
-
-                       // Call it again if not all entries were purged
-                       if (($count > 0) AND get_config("system", "worker")) {
-                               proc_run(PRIORITY_LOW, 'include/dbclean.php', 5);
-                       }
                }
                $db->qclose();
                logger("Done deleting orphaned data from notify-threads table");
@@ -136,11 +124,6 @@ function remove_orphans($stage = 0) {
                        while ($orphan = $db->qfetch()) {
                                q("DELETE FROM `sign` WHERE `iid` = %d", intval($orphan["iid"]));
                        }
-
-                       // Call it again if not all entries were purged
-                       if (($count > 0) AND get_config("system", "worker")) {
-                               proc_run(PRIORITY_LOW, 'include/dbclean.php', 6);
-                       }
                }
                $db->qclose();
                logger("Done deleting orphaned data from sign table");
@@ -155,15 +138,16 @@ function remove_orphans($stage = 0) {
                        while ($orphan = $db->qfetch()) {
                                q("DELETE FROM `term` WHERE `oid` = %d", intval($orphan["oid"]));
                        }
-
-                       // Call it again if not all entries were purged
-                       if (($count > 0) AND get_config("system", "worker")) {
-                               proc_run(PRIORITY_LOW, 'include/dbclean.php', 7);
-                       }
                }
                $db->qclose();
                logger("Done deleting orphaned data from term table");
        }
+
+       // Call it again if not all entries were purged
+       if (($stage != 0) AND ($count > 0) AND get_config("system", "worker")) {
+               proc_run(PRIORITY_LOW, 'include/dbclean.php');
+       }
+
 }
 
 if (array_search(__file__,get_included_files())===0){