mirror of
https://github.com/friendica/friendica
synced 2024-12-23 06:00:15 +00:00
run dbclean as long as there is some data to be purged
This commit is contained in:
parent
4d966e1e21
commit
b5d004e1d7
2 changed files with 21 additions and 47 deletions
|
@ -126,17 +126,7 @@ function cron_run(&$argv, &$argc){
|
||||||
|
|
||||||
proc_run(PRIORITY_LOW, 'include/expire.php');
|
proc_run(PRIORITY_LOW, 'include/expire.php');
|
||||||
|
|
||||||
if (get_config("system", "worker")) {
|
proc_run(PRIORITY_LOW, 'include/dbclean.php');
|
||||||
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');
|
|
||||||
}
|
|
||||||
|
|
||||||
cron_update_photo_albums();
|
cron_update_photo_albums();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,18 @@ function dbclean_run(&$argv, &$argc) {
|
||||||
} else {
|
} else {
|
||||||
$stage = 0;
|
$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) {
|
function remove_orphans($stage = 0) {
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
|
$count = 0;
|
||||||
|
|
||||||
if (($stage == 1) OR ($stage == 0)) {
|
if (($stage == 1) OR ($stage == 0)) {
|
||||||
logger("Deleting old global item entries from item table without user copy");
|
logger("Deleting old global item entries from item table without user copy");
|
||||||
if ($db->q("SELECT `id` FROM `item` WHERE `uid` = 0
|
if ($db->q("SELECT `id` FROM `item` WHERE `uid` = 0
|
||||||
|
@ -45,11 +58,6 @@ function remove_orphans($stage = 0) {
|
||||||
while ($orphan = $db->qfetch()) {
|
while ($orphan = $db->qfetch()) {
|
||||||
q("DELETE FROM `item` WHERE `id` = %d", intval($orphan["id"]));
|
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();
|
$db->qclose();
|
||||||
logger("Done deleting old global item entries from item table without user copy");
|
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()) {
|
while ($orphan = $db->qfetch()) {
|
||||||
q("DELETE FROM `item` WHERE `id` = %d", intval($orphan["id"]));
|
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();
|
$db->qclose();
|
||||||
logger("Done deleting items without parents");
|
logger("Done deleting items without parents");
|
||||||
|
@ -81,11 +84,6 @@ function remove_orphans($stage = 0) {
|
||||||
while ($orphan = $db->qfetch()) {
|
while ($orphan = $db->qfetch()) {
|
||||||
q("DELETE FROM `thread` WHERE `iid` = %d", intval($orphan["iid"]));
|
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();
|
$db->qclose();
|
||||||
logger("Done deleting orphaned data from thread table");
|
logger("Done deleting orphaned data from thread table");
|
||||||
|
@ -99,11 +97,6 @@ function remove_orphans($stage = 0) {
|
||||||
while ($orphan = $db->qfetch()) {
|
while ($orphan = $db->qfetch()) {
|
||||||
q("DELETE FROM `notify` WHERE `iid` = %d", intval($orphan["iid"]));
|
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();
|
$db->qclose();
|
||||||
logger("Done deleting orphaned data from notify table");
|
logger("Done deleting orphaned data from notify table");
|
||||||
|
@ -117,11 +110,6 @@ function remove_orphans($stage = 0) {
|
||||||
while ($orphan = $db->qfetch()) {
|
while ($orphan = $db->qfetch()) {
|
||||||
q("DELETE FROM `notify-threads` WHERE `id` = %d", intval($orphan["id"]));
|
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();
|
$db->qclose();
|
||||||
logger("Done deleting orphaned data from notify-threads table");
|
logger("Done deleting orphaned data from notify-threads table");
|
||||||
|
@ -136,11 +124,6 @@ function remove_orphans($stage = 0) {
|
||||||
while ($orphan = $db->qfetch()) {
|
while ($orphan = $db->qfetch()) {
|
||||||
q("DELETE FROM `sign` WHERE `iid` = %d", intval($orphan["iid"]));
|
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();
|
$db->qclose();
|
||||||
logger("Done deleting orphaned data from sign table");
|
logger("Done deleting orphaned data from sign table");
|
||||||
|
@ -155,15 +138,16 @@ function remove_orphans($stage = 0) {
|
||||||
while ($orphan = $db->qfetch()) {
|
while ($orphan = $db->qfetch()) {
|
||||||
q("DELETE FROM `term` WHERE `oid` = %d", intval($orphan["oid"]));
|
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();
|
$db->qclose();
|
||||||
logger("Done deleting orphaned data from term table");
|
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){
|
if (array_search(__file__,get_included_files())===0){
|
||||||
|
|
Loading…
Reference in a new issue