]> git.mxchange.org Git - friendica.git/commitdiff
Moved expiring of item content
authorMichael <heluecht@pirati.ca>
Sun, 29 Jul 2018 03:54:34 +0000 (03:54 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 29 Jul 2018 03:54:34 +0000 (03:54 +0000)
src/Model/Item.php
src/Worker/Expire.php

index bc883aa3cc5a78cd661a7a63b83adfd747125dc8..11de99bc46f8ab02325ee393d754c2c78b692d56 100644 (file)
@@ -979,7 +979,8 @@ class Item extends BaseObject
                // locate item to be deleted
                $fields = ['id', 'uri', 'uid', 'parent', 'parent-uri', 'origin',
                        '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]);
                if (!DBA::isResult($item)) {
                        logger('Item with ID ' . $item_id . " hasn't been found.", LOGGER_DEBUG);
@@ -1042,11 +1043,7 @@ class Item extends BaseObject
                self::deleteTagsFromItem($item);
 
                // Set the item to "deleted"
-               // This erasing of item content is superfluous for items with a matching item-content.
-               // 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' => ''];
+               $item_fields = ['deleted' => true, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()];
                DBA::update('item', $item_fields, ['id' => $item['id']]);
 
                Term::insertFromTagFieldByItemId($item['id'], '');
@@ -1059,6 +1056,18 @@ class Item extends BaseObject
 
                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 ($item['id'] == $item['parent']) {
                        self::delete(['parent' => $item['parent'], 'deleted' => false], $priority);
index efb2cb03db8a152da4794bb76f830e7fc1af7ac0..b6096b5849405d11b2f68fec6a81c245157a44ad 100644 (file)
@@ -29,20 +29,9 @@ class Expire
                        logger('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', 'iaid', 'icid', 'psid'],  $condition);
+                       $rows = DBA::select('item', ['id'],  $condition);
                        while ($row = DBA::fetch($rows)) {
                                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);