From: Hypolite Petovan Date: Tue, 3 Mar 2020 06:48:06 +0000 (-0500) Subject: Add guid context to item deletion logging X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=86a6268aac035cf0d789c718115dfc1999e608b3;p=friendica.git Add guid context to item deletion logging --- diff --git a/src/Model/Item.php b/src/Model/Item.php index de719a3c7a..df5fc1976e 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1938,7 +1938,7 @@ class Item if ($entries > 1) { // There are duplicates. We delete our just created entry. - Logger::notice('Delete duplicated item', ['id' => $current_post, 'uri' => $item['uri'], 'uid' => $item['uid']]); + Logger::notice('Delete duplicated item', ['id' => $current_post, 'uri' => $item['uri'], 'uid' => $item['uid'], 'guid' => $item['guid']]); // Yes, we could do a rollback here - but we are having many users with MyISAM. DBA::delete('item', ['id' => $current_post]); @@ -2721,7 +2721,7 @@ class Item if (!$mention) { if (($community_page || $prvgroup) && !$item['wall'] && !$item['origin'] && ($item['id'] == $item['parent'])) { - Logger::notice('Delete private group/communiy top-level item without mention', ['id' => $item_id]); + Logger::notice('Delete private group/communiy top-level item without mention', ['id' => $item_id, 'guid'=> $item['guid']]); DBA::delete('item', ['id' => $item_id]); return true; } diff --git a/src/Worker/DBClean.php b/src/Worker/DBClean.php index 7fbc65e29e..19d95b6752 100644 --- a/src/Worker/DBClean.php +++ b/src/Worker/DBClean.php @@ -98,7 +98,7 @@ class DBClean { $last_id = DI::config()->get('system', 'dbclean-last-id-1', 0); Logger::log("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 + $r = DBA::p("SELECT `id`, `guid` 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 ? DAY AND `id` >= ? ORDER BY `id` LIMIT ?", $days_unclaimed, $last_id, $limit); @@ -107,7 +107,7 @@ class DBClean { Logger::log("found global item orphans: ".$count); while ($orphan = DBA::fetch($r)) { $last_id = $orphan["id"]; - Logger::notice('Delete global orphan item', ['id' => $orphan["id"]]); + Logger::notice('Delete global orphan item', ['id' => $orphan['id'], 'guid' => $orphan['guid']]); DBA::delete('item', ['id' => $orphan["id"]]); } Worker::add(PRIORITY_MEDIUM, 'DBClean', 1, $last_id); @@ -122,7 +122,7 @@ class DBClean { $last_id = DI::config()->get('system', 'dbclean-last-id-2', 0); Logger::log("Deleting items without parents. Last ID: ".$last_id); - $r = DBA::p("SELECT `id` FROM `item` + $r = DBA::p("SELECT `id`, `guid` FROM `item` WHERE NOT EXISTS (SELECT `id` FROM `item` AS `i` WHERE `item`.`parent` = `i`.`id`) AND `id` >= ? ORDER BY `id` LIMIT ?", $last_id, $limit); $count = DBA::numRows($r); @@ -130,7 +130,7 @@ class DBClean { Logger::log("found item orphans without parents: ".$count); while ($orphan = DBA::fetch($r)) { $last_id = $orphan["id"]; - Logger::notice('Delete orphan item', ['id' => $orphan["id"]]); + Logger::notice('Delete orphan item', ['id' => $orphan['id'], 'guid' => $orphan['guid']]); DBA::delete('item', ['id' => $orphan["id"]]); } Worker::add(PRIORITY_MEDIUM, 'DBClean', 2, $last_id); @@ -319,7 +319,7 @@ class DBClean { $till_id = DI::config()->get('system', 'dbclean-last-id-8', 0); Logger::log("Deleting old global item entries from expired threads from ID ".$last_id." to ID ".$till_id); - $r = DBA::p("SELECT `id` FROM `item` WHERE `uid` = 0 AND + $r = DBA::p("SELECT `id`, `guid` 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` >= ? AND `id` <= ? ORDER BY `id` LIMIT ?", $last_id, $till_id, $limit); @@ -328,7 +328,7 @@ class DBClean { Logger::log("found global item entries from expired threads: ".$count); while ($orphan = DBA::fetch($r)) { $last_id = $orphan["id"]; - Logger::notice('Delete expired thread item', ['id' => $orphan["id"]]); + Logger::notice('Delete expired thread item', ['id' => $orphan['id'], 'guid' => $orphan['guid']]); DBA::delete('item', ['id' => $orphan["id"]]); } Worker::add(PRIORITY_MEDIUM, 'DBClean', 9, $last_id); diff --git a/src/Worker/Expire.php b/src/Worker/Expire.php index dfbf9738e6..bccb439e50 100644 --- a/src/Worker/Expire.php +++ b/src/Worker/Expire.php @@ -43,9 +43,9 @@ class Expire Logger::log('Delete expired items', Logger::DEBUG); // physically remove anything that has been deleted for more than two months $condition = ["`deleted` AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY"]; - $rows = DBA::select('item', ['id'], $condition); + $rows = DBA::select('item', ['id', 'guid'], $condition); while ($row = DBA::fetch($rows)) { - Logger::notice('Delete expired item', ['id' => $row["id"]]); + Logger::notice('Delete expired item', ['id' => $row['id'], 'guid' => $row['guid']]); DBA::delete('item', ['id' => $row['id']]); } DBA::close($rows); diff --git a/src/Worker/RemoveContact.php b/src/Worker/RemoveContact.php index 40e3a67fcf..cfec2c1846 100644 --- a/src/Worker/RemoveContact.php +++ b/src/Worker/RemoveContact.php @@ -41,9 +41,9 @@ class RemoveContact { // Now we delete the contact and all depending tables $condition = ['uid' => $contact['uid'], 'contact-id' => $id]; do { - $items = Item::select(['id'], $condition, ['limit' => 100]); + $items = Item::select(['id', 'guid'], $condition, ['limit' => 100]); while ($item = Item::fetch($items)) { - Logger::notice('Delete removed contact item', ['id' => $item["id"]]); + Logger::notice('Delete removed contact item', ['id' => $item['id'], 'guid' => $item['guid']]); DBA::delete('item', ['id' => $item['id']]); } DBA::close($items);