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]);
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;
}
$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);
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);
$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);
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);
$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);
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);
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);
// 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);