]> git.mxchange.org Git - friendica.git/commitdiff
Add guid context to item deletion logging
authorHypolite Petovan <hypolite@mrpetovan.com>
Tue, 3 Mar 2020 06:48:06 +0000 (01:48 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Tue, 3 Mar 2020 17:01:03 +0000 (12:01 -0500)
src/Model/Item.php
src/Worker/DBClean.php
src/Worker/Expire.php
src/Worker/RemoveContact.php

index de719a3c7adc075246c53c260c8c6365fa7b4404..df5fc1976ed17398ed9f28b65b778fe04f302418 100644 (file)
@@ -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;
                        }
index 7fbc65e29ee111aa30fe789e3cedb33820db6931..19d95b67526898a900152701b8be3ce7141b4fdb 100644 (file)
@@ -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);
index dfbf9738e6379fbaaa301ac8183dba10a1bf10d1..bccb439e500dfc98e0126fb06adca00c72ed050d 100644 (file)
@@ -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);
index 40e3a67fcf8fd933767c782868bcfa975b93b814..cfec2c1846ce724f2cbf45ae0efda3b54ba7c12f 100644 (file)
@@ -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);