Merge pull request #8354 from MrPetovan/bug/7134-local-post-deleted
Add debug for item deletion
This commit is contained in:
commit
8770a2089e
4 changed files with 10 additions and 5 deletions
|
@ -1112,6 +1112,7 @@ class Item
|
||||||
*/
|
*/
|
||||||
public static function deleteById($item_id, $priority = PRIORITY_HIGH)
|
public static function deleteById($item_id, $priority = PRIORITY_HIGH)
|
||||||
{
|
{
|
||||||
|
Logger::notice('Delete item by id', ['id' => $item_id, 'callstack' => System::callstack()]);
|
||||||
// locate item to be deleted
|
// locate item to be deleted
|
||||||
$fields = ['id', 'uri', 'uid', 'parent', 'parent-uri', 'origin',
|
$fields = ['id', 'uri', 'uid', 'parent', 'parent-uri', 'origin',
|
||||||
'deleted', 'file', 'resource-id', 'event-id', 'attach',
|
'deleted', 'file', 'resource-id', 'event-id', 'attach',
|
||||||
|
@ -1934,7 +1935,7 @@ class Item
|
||||||
|
|
||||||
if ($entries > 1) {
|
if ($entries > 1) {
|
||||||
// There are duplicates. We delete our just created entry.
|
// There are duplicates. We delete our just created entry.
|
||||||
Logger::log('Duplicated post occurred. uri = ' . $item['uri'] . ' uid = ' . $item['uid']);
|
Logger::notice('Delete duplicated item', ['id' => $current_post, 'uri' => $item['uri'], 'uid' => $item['uid']]);
|
||||||
|
|
||||||
// Yes, we could do a rollback here - but we are having many users with MyISAM.
|
// Yes, we could do a rollback here - but we are having many users with MyISAM.
|
||||||
DBA::delete('item', ['id' => $current_post]);
|
DBA::delete('item', ['id' => $current_post]);
|
||||||
|
@ -2717,9 +2718,7 @@ class Item
|
||||||
if (!$mention) {
|
if (!$mention) {
|
||||||
if (($community_page || $prvgroup) &&
|
if (($community_page || $prvgroup) &&
|
||||||
!$item['wall'] && !$item['origin'] && ($item['id'] == $item['parent'])) {
|
!$item['wall'] && !$item['origin'] && ($item['id'] == $item['parent'])) {
|
||||||
// mmh.. no mention.. community page or private group... no wall.. no origin.. top-post (not a comment)
|
Logger::notice('Delete private group/communiy top-level item without mention', ['id' => $item_id]);
|
||||||
// delete it!
|
|
||||||
Logger::log("no-mention top-level post to community or private group. delete.");
|
|
||||||
DBA::delete('item', ['id' => $item_id]);
|
DBA::delete('item', ['id' => $item_id]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3367,7 +3366,7 @@ class Item
|
||||||
$condition = ["`uri` = ? AND NOT `deleted` AND NOT (`uid` IN (?, 0))", $itemuri, $item["uid"]];
|
$condition = ["`uri` = ? AND NOT `deleted` AND NOT (`uid` IN (?, 0))", $itemuri, $item["uid"]];
|
||||||
if (!self::exists($condition)) {
|
if (!self::exists($condition)) {
|
||||||
DBA::delete('item', ['uri' => $itemuri, 'uid' => 0]);
|
DBA::delete('item', ['uri' => $itemuri, 'uid' => 0]);
|
||||||
Logger::log("deleteThread: Deleted shadow for item ".$itemuri, Logger::DEBUG);
|
Logger::debug('Deleted shadow item', ['id' => $itemid, 'uri' => $itemuri]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,6 +107,7 @@ class DBClean {
|
||||||
Logger::log("found global item orphans: ".$count);
|
Logger::log("found global item orphans: ".$count);
|
||||||
while ($orphan = DBA::fetch($r)) {
|
while ($orphan = DBA::fetch($r)) {
|
||||||
$last_id = $orphan["id"];
|
$last_id = $orphan["id"];
|
||||||
|
Logger::notice('Delete global orphan item', ['id' => $orphan["id"]]);
|
||||||
DBA::delete('item', ['id' => $orphan["id"]]);
|
DBA::delete('item', ['id' => $orphan["id"]]);
|
||||||
}
|
}
|
||||||
Worker::add(PRIORITY_MEDIUM, 'DBClean', 1, $last_id);
|
Worker::add(PRIORITY_MEDIUM, 'DBClean', 1, $last_id);
|
||||||
|
@ -129,6 +130,7 @@ class DBClean {
|
||||||
Logger::log("found item orphans without parents: ".$count);
|
Logger::log("found item orphans without parents: ".$count);
|
||||||
while ($orphan = DBA::fetch($r)) {
|
while ($orphan = DBA::fetch($r)) {
|
||||||
$last_id = $orphan["id"];
|
$last_id = $orphan["id"];
|
||||||
|
Logger::notice('Delete orphan item', ['id' => $orphan["id"]]);
|
||||||
DBA::delete('item', ['id' => $orphan["id"]]);
|
DBA::delete('item', ['id' => $orphan["id"]]);
|
||||||
}
|
}
|
||||||
Worker::add(PRIORITY_MEDIUM, 'DBClean', 2, $last_id);
|
Worker::add(PRIORITY_MEDIUM, 'DBClean', 2, $last_id);
|
||||||
|
@ -326,6 +328,7 @@ class DBClean {
|
||||||
Logger::log("found global item entries from expired threads: ".$count);
|
Logger::log("found global item entries from expired threads: ".$count);
|
||||||
while ($orphan = DBA::fetch($r)) {
|
while ($orphan = DBA::fetch($r)) {
|
||||||
$last_id = $orphan["id"];
|
$last_id = $orphan["id"];
|
||||||
|
Logger::notice('Delete expired thread item', ['id' => $orphan["id"]]);
|
||||||
DBA::delete('item', ['id' => $orphan["id"]]);
|
DBA::delete('item', ['id' => $orphan["id"]]);
|
||||||
}
|
}
|
||||||
Worker::add(PRIORITY_MEDIUM, 'DBClean', 9, $last_id);
|
Worker::add(PRIORITY_MEDIUM, 'DBClean', 9, $last_id);
|
||||||
|
|
|
@ -45,6 +45,7 @@ class Expire
|
||||||
$condition = ["`deleted` AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY"];
|
$condition = ["`deleted` AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY"];
|
||||||
$rows = DBA::select('item', ['id'], $condition);
|
$rows = DBA::select('item', ['id'], $condition);
|
||||||
while ($row = DBA::fetch($rows)) {
|
while ($row = DBA::fetch($rows)) {
|
||||||
|
Logger::notice('Delete expired item', ['id' => $row["id"]]);
|
||||||
DBA::delete('item', ['id' => $row['id']]);
|
DBA::delete('item', ['id' => $row['id']]);
|
||||||
}
|
}
|
||||||
DBA::close($rows);
|
DBA::close($rows);
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
namespace Friendica\Worker;
|
namespace Friendica\Worker;
|
||||||
|
|
||||||
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
@ -42,6 +43,7 @@ class RemoveContact {
|
||||||
do {
|
do {
|
||||||
$items = Item::select(['id'], $condition, ['limit' => 100]);
|
$items = Item::select(['id'], $condition, ['limit' => 100]);
|
||||||
while ($item = Item::fetch($items)) {
|
while ($item = Item::fetch($items)) {
|
||||||
|
Logger::notice('Delete removed contact item', ['id' => $item["id"]]);
|
||||||
DBA::delete('item', ['id' => $item['id']]);
|
DBA::delete('item', ['id' => $item['id']]);
|
||||||
}
|
}
|
||||||
DBA::close($items);
|
DBA::close($items);
|
||||||
|
|
Loading…
Reference in a new issue