From 2f52afeeace458ff454af041a61536bbbf7382eb Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 7 Jan 2021 17:34:23 +0000 Subject: [PATCH 1/3] Issue 9746: Delete uri-id orphans --- update.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/update.php b/update.php index 285252770a..958e974f9d 100644 --- a/update.php +++ b/update.php @@ -831,6 +831,10 @@ function pre_update_1377() return Update::FAILED; } + if (!DBA::e("DELETE FROM `diaspora-interaction` WHERE `uri-id` NOT IN (SELECT `id` FROM `item-uri`)")) { + return Update::FAILED; + } + if (!DBA::e("DELETE FROM `notify` WHERE `uri-id` NOT IN (SELECT `id` FROM `item-uri`)")) { return Update::FAILED; } @@ -838,7 +842,6 @@ function pre_update_1377() if (!DBA::e("UPDATE `notify` SET `parent-uri-id` = NULL WHERE `parent-uri-id` = 0")) { return Update::FAILED; } - if (!DBA::e("DELETE FROM `notify` WHERE `parent-uri-id` NOT IN (SELECT `id` FROM `item-uri`)")) { return Update::FAILED; } From 9ba2bd07362f7fb475ba542d69b34f733bc79983 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 7 Jan 2021 18:13:40 +0000 Subject: [PATCH 2/3] Ensure to only execute this if the table exists --- update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update.php b/update.php index 958e974f9d..ffcfa6a90f 100644 --- a/update.php +++ b/update.php @@ -831,7 +831,7 @@ function pre_update_1377() return Update::FAILED; } - if (!DBA::e("DELETE FROM `diaspora-interaction` WHERE `uri-id` NOT IN (SELECT `id` FROM `item-uri`)")) { + if (DBStructure::existsTable('diaspora-interaction') && !DBA::e("DELETE FROM `diaspora-interaction` WHERE `uri-id` NOT IN (SELECT `id` FROM `item-uri`)")) { return Update::FAILED; } From a119c030fdfe242aa1d3b01b59ffc49fbc8845a8 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 7 Jan 2021 18:24:26 +0000 Subject: [PATCH 3/3] Add some more tables to remove orphans --- update.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/update.php b/update.php index ffcfa6a90f..b5d1784894 100644 --- a/update.php +++ b/update.php @@ -835,6 +835,14 @@ function pre_update_1377() return Update::FAILED; } + if (DBStructure::existsTable('item-activity') && !DBA::e("DELETE FROM `item-activity` WHERE `uri-id` NOT IN (SELECT `id` FROM `item-uri`)")) { + return Update::FAILED; + } + + if (DBStructure::existsTable('item-content') && !DBA::e("DELETE FROM `item-content` WHERE `uri-id` NOT IN (SELECT `id` FROM `item-uri`)")) { + return Update::FAILED; + } + if (!DBA::e("DELETE FROM `notify` WHERE `uri-id` NOT IN (SELECT `id` FROM `item-uri`)")) { return Update::FAILED; }