Moved expiring of item content
This commit is contained in:
parent
489d3daa94
commit
dc9b10fb09
2 changed files with 16 additions and 18 deletions
|
@ -979,7 +979,8 @@ class Item extends BaseObject
|
||||||
// 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',
|
||||||
'verb', 'object-type', 'object', 'target', 'contact-id'];
|
'verb', 'object-type', 'object', 'target', 'contact-id',
|
||||||
|
'icid', 'iaid', 'psid'];
|
||||||
$item = self::selectFirst($fields, ['id' => $item_id]);
|
$item = self::selectFirst($fields, ['id' => $item_id]);
|
||||||
if (!DBA::isResult($item)) {
|
if (!DBA::isResult($item)) {
|
||||||
logger('Item with ID ' . $item_id . " hasn't been found.", LOGGER_DEBUG);
|
logger('Item with ID ' . $item_id . " hasn't been found.", LOGGER_DEBUG);
|
||||||
|
@ -1042,11 +1043,7 @@ class Item extends BaseObject
|
||||||
self::deleteTagsFromItem($item);
|
self::deleteTagsFromItem($item);
|
||||||
|
|
||||||
// Set the item to "deleted"
|
// Set the item to "deleted"
|
||||||
// This erasing of item content is superfluous for items with a matching item-content.
|
$item_fields = ['deleted' => true, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()];
|
||||||
// But for the next time we will still have old content in the item table.
|
|
||||||
$item_fields = ['deleted' => true, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow(),
|
|
||||||
'body' => '', 'title' => '', 'content-warning' => '', 'rendered-hash' => '', 'rendered-html' => '',
|
|
||||||
'object' => '', 'target' => '', 'tag' => '', 'postopts' => '', 'attach' => '', 'file' => ''];
|
|
||||||
DBA::update('item', $item_fields, ['id' => $item['id']]);
|
DBA::update('item', $item_fields, ['id' => $item['id']]);
|
||||||
|
|
||||||
Term::insertFromTagFieldByItemId($item['id'], '');
|
Term::insertFromTagFieldByItemId($item['id'], '');
|
||||||
|
@ -1059,6 +1056,18 @@ class Item extends BaseObject
|
||||||
|
|
||||||
DBA::delete('item-delivery-data', ['iid' => $item['id']]);
|
DBA::delete('item-delivery-data', ['iid' => $item['id']]);
|
||||||
|
|
||||||
|
if (!empty($item['iaid']) && !DBA::exists('item', ['iaid' => $item['iaid'], 'deleted' => false])) {
|
||||||
|
DBA::delete('item-activity', ['id' => $item['iaid']]);
|
||||||
|
}
|
||||||
|
if (!empty($item['icid']) && !DBA::exists('item', ['icid' => $item['icid'], 'deleted' => false])) {
|
||||||
|
DBA::delete('item-content', ['id' => $item['icid']]);
|
||||||
|
}
|
||||||
|
// When the permission set will be used in photo and events as well,
|
||||||
|
// this query here needs to be extended.
|
||||||
|
if (!empty($item['psid']) && !DBA::exists('item', ['psid' => $item['psid'], 'deleted' => false])) {
|
||||||
|
DBA::delete('permissionset', ['id' => $item['psid']]);
|
||||||
|
}
|
||||||
|
|
||||||
// If it's the parent of a comment thread, kill all the kids
|
// If it's the parent of a comment thread, kill all the kids
|
||||||
if ($item['id'] == $item['parent']) {
|
if ($item['id'] == $item['parent']) {
|
||||||
self::delete(['parent' => $item['parent'], 'deleted' => false], $priority);
|
self::delete(['parent' => $item['parent'], 'deleted' => false], $priority);
|
||||||
|
|
|
@ -29,20 +29,9 @@ class Expire
|
||||||
logger('Delete expired items', LOGGER_DEBUG);
|
logger('Delete expired items', LOGGER_DEBUG);
|
||||||
// physically remove anything that has been deleted for more than two months
|
// physically remove anything that has been deleted for more than two months
|
||||||
$condition = ["`deleted` AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY"];
|
$condition = ["`deleted` AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY"];
|
||||||
$rows = DBA::select('item', ['id', 'iaid', 'icid', 'psid'], $condition);
|
$rows = DBA::select('item', ['id'], $condition);
|
||||||
while ($row = DBA::fetch($rows)) {
|
while ($row = DBA::fetch($rows)) {
|
||||||
DBA::delete('item', ['id' => $row['id']]);
|
DBA::delete('item', ['id' => $row['id']]);
|
||||||
if (!empty($row['iaid']) && !DBA::exists('item', ['iaid' => $row['iaid']])) {
|
|
||||||
DBA::delete('item-activity', ['id' => $row['iaid']]);
|
|
||||||
}
|
|
||||||
if (!empty($row['icid']) && !DBA::exists('item', ['icid' => $row['icid']])) {
|
|
||||||
DBA::delete('item-content', ['id' => $row['icid']]);
|
|
||||||
}
|
|
||||||
// When the permission set will be used in photo and events as well.
|
|
||||||
// this query here needs to be extended.
|
|
||||||
if (!empty($row['psid']) && !DBA::exists('item', ['psid' => $row['psid']])) {
|
|
||||||
DBA::delete('permissionset', ['id' => $row['psid']]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
DBA::close($rows);
|
DBA::close($rows);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue