]> git.mxchange.org Git - friendica.git/commitdiff
"item" is replaced whenever possible at the moment
authorMichael <heluecht@pirati.ca>
Sat, 6 Feb 2021 13:42:21 +0000 (13:42 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 6 Feb 2021 13:42:21 +0000 (13:42 +0000)
src/Database/DBA.php
src/Database/Database.php
src/Model/Item.php
src/Module/Admin/Site.php
src/Module/Settings/UserExport.php
src/Worker/CleanItemUri.php
src/Worker/Expire.php
src/Worker/MergeContact.php
src/Worker/RepairDatabase.php

index 41ab456b899b4f2f5af492567aa16f2314338402..3bdcfb617a507008e94c24cbff25f08393f286b1 100644 (file)
@@ -478,7 +478,7 @@ class DBA
         * @return boolean|object
         *
         * Example:
-        * $table = "item";
+        * $table = "post";
         * $fields = array("id", "uri", "uid", "network");
         *
         * $condition = array("uid" => 1, "network" => 'dspr');
@@ -505,7 +505,7 @@ class DBA
         * @return int
         *
         * Example:
-        * $table = "item";
+        * $table = "post";
         *
         * $condition = ["uid" => 1, "network" => 'dspr'];
         * or:
index ae06f00e26cd5562e425008b773a833eb777855e..ec95a8301c6f00e4092242bf18af7cd1ee64beba 100644 (file)
@@ -1512,7 +1512,7 @@ class Database
         *
         *
         * Example:
-        * $table = 'item';
+        * $table = 'post';
         * or:
         * $table = ['schema' => 'table'];
         * @see DBA::buildTableString()
@@ -1575,7 +1575,7 @@ class Database
         * @return int
         *
         * Example:
-        * $table = "item";
+        * $table = "post";
         *
         * $condition = ["uid" => 1, "network" => 'dspr'];
         * or:
index 106d50e764cb1bb7d09992b37b209f2e0d01f024..8eeb77d32b86c8c6bb4311317cf713738e1b1b40 100644 (file)
@@ -319,7 +319,7 @@ class Item
 
                // Set the item to "deleted"
                $item_fields = ['deleted' => true, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()];
-               DBA::update('item', $item_fields, ['id' => $item['id']]);
+               Post::update($item_fields, ['id' => $item['id']]);
 
                Post\Category::storeTextByURIId($item['uri-id'], $item['uid'], '');
                self::deleteThread($item['id'], $item['parent-uri-id']);
@@ -919,7 +919,7 @@ class Item
                        $item["global"] = true;
 
                        // Set the global flag on all items if this was a global item entry
-                       DBA::update('item', ['global' => true], ['uri-id' => $item['uri-id']]);
+                       Post::update(['global' => true], ['uri-id' => $item['uri-id']]);
                } else {
                        $item['global'] = Post::exists(['uid' => 0, 'uri-id' => $item['uri-id']]);
                }
@@ -1068,9 +1068,9 @@ class Item
                }
 
                if ($update_commented) {
-                       DBA::update('item', ['commented' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
+                       Post::update(['commented' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
                } else {
-                       DBA::update('item', ['changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
+                       Post::update(['changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
                }
 
                if ($item['gravity'] === GRAVITY_PARENT) {
index 0e0753a401c263697f0fca2453d1e085b9988398..8cd2648cf6d559f0ee86fd179ec9b33ac93c2923 100644 (file)
@@ -104,7 +104,7 @@ class Site extends BaseAdmin
                        // update profile links in the format "http://server.tld"
                        update_table($a, "profile", ['photo', 'thumb'], $old_url, $new_url);
                        update_table($a, "contact", ['photo', 'thumb', 'micro', 'url', 'nurl', 'alias', 'request', 'notify', 'poll', 'confirm', 'poco', 'avatar'], $old_url, $new_url);
-                       update_table($a, "item", ['owner-link', 'author-link', 'body', 'plink', 'tag'], $old_url, $new_url);
+                       update_table($a, "post-content", ['body'], $old_url, $new_url);
 
                        // update profile addresses in the format "user@server.tld"
                        update_table($a, "contact", ['addr'], $old_host, $new_host);
index 42ee4eb1f4649642493e91cc181c68b616269c07..2b668182e42148bf6a060b87dfdc8e3cded6e29d 100644 (file)
@@ -242,7 +242,7 @@ class UserExport extends BaseSettings
                self::exportAccount($a);
                echo "\n";
 
-               $total = DBA::count('item', ['uid' => local_user()]);
+               $total = Post::count(['uid' => local_user()]);
                // chunk the output to avoid exhausting memory
 
                for ($x = 0; $x < $total; $x += 500) {
index d7a99153f69efaddc14427490ffb916ec968697d..268fe29dc7a8bf364d426b696ba3aec0951f5dc3 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Worker;
 
 use Friendica\Core\Logger;
 use Friendica\Database\DBA;
+use Friendica\Model\Post;
 
 class CleanItemUri
 {
@@ -33,7 +34,7 @@ class CleanItemUri
        {
                // We have to avoid deleting newly created "item-uri" entries.
                // So we fetch a post that had been stored yesterday and only delete older ones.
-               $item = DBA::selectFirst('item', ['uri-id'], ["`uid` = ? AND `received` < UTC_TIMESTAMP() - INTERVAL ? DAY", 0, 1],
+               $item = Post::selectFirst(['uri-id'], ["`uid` = ? AND `received` < UTC_TIMESTAMP() - INTERVAL ? DAY", 0, 1],
                        ['order' => ['received' => true]]);
                if (empty($item['uri-id'])) {
                        Logger::warning('No item with uri-id found - we better quit here');
index 70a4f913a4a19f33d69469da3f2bd693da29f264..ca92bd1eeec2823b0bcaaf645af8c2a1206b138a 100644 (file)
@@ -44,11 +44,12 @@ 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', 'guid', 'uri-id', 'uid'],  $condition);
-                       while ($row = DBA::fetch($rows)) {
+                       $rows = Post::select(['id', 'guid', 'uri-id', 'uid'],  $condition);
+                       while ($row = Post::fetch($rows)) {
                                Logger::info('Delete expired item', ['id' => $row['id'], 'guid' => $row['guid']]);
                                DBA::delete('item', ['id' => $row['id']]);
                                Post\User::delete(['uri-id' => $row['uri-id'], 'uid' => $row['uid']]);
+                               Post\ThreadUser::delete(['uri-id' => $row['uri-id'], 'uid' => $row['uid']]);
                        }
                        DBA::close($rows);
 
index e04dfb6ac880afdde105767f4a850445912e7882..7a4c07540b2e2347b233f1020dc2971843dbe14b 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Worker;
 
 use Friendica\Core\Logger;
 use Friendica\Database\DBA;
+use Friendica\Model\Post;
 
 class MergeContact
 {
@@ -43,8 +44,7 @@ class MergeContact
                Logger::info('Handling duplicate', ['search' => $old_cid, 'replace' => $new_cid]);
 
                // Search and replace
-               DBA::update('item', ['contact-id' => $new_cid], ['contact-id' => $old_cid]);
-               DBA::update('thread', ['contact-id' => $new_cid], ['contact-id' => $old_cid]);
+               Post::update(['contact-id' => $new_cid], ['contact-id' => $old_cid]);
                DBA::update('mail', ['contact-id' => $new_cid], ['contact-id' => $old_cid]);
                DBA::update('photo', ['contact-id' => $new_cid], ['contact-id' => $old_cid]);
                DBA::update('event', ['cid' => $new_cid], ['cid' => $old_cid]);
@@ -53,11 +53,9 @@ class MergeContact
                if ($uid == 0) {
                        DBA::update('post-tag', ['cid' => $new_cid], ['cid' => $old_cid]);
                        DBA::delete('post-tag', ['cid' => $old_cid]);
-                       DBA::update('item', ['author-id' => $new_cid], ['author-id' => $old_cid]);
-                       DBA::update('item', ['owner-id' => $new_cid], ['owner-id' => $old_cid]);
-                       DBA::update('item', ['causer-id' => $new_cid], ['causer-id' => $old_cid]);
-                       DBA::update('thread', ['author-id' => $new_cid], ['author-id' => $old_cid]);
-                       DBA::update('thread', ['owner-id' => $new_cid], ['owner-id' => $old_cid]);
+                       Post::update(['author-id' => $new_cid], ['author-id' => $old_cid]);
+                       Post::update(['owner-id' => $new_cid], ['owner-id' => $old_cid]);
+                       Post::update(['causer-id' => $new_cid], ['causer-id' => $old_cid]);
                } else {
                        /// @todo Check if some other data needs to be adjusted as well, possibly the "rel" status?
                }
index 3524c3d15a4bbc79f86613cb70d344d0813ced51..ef9035d89b07896477a4fd7d40f2bac05fe8f6ea 100644 (file)
@@ -26,7 +26,7 @@ use Friendica\Model\ItemURI;
 
 /**
  * Do some repairs in database entries
- *
+ * @todo This class can be deleted without replacement when the item table is removed
  */
 class RepairDatabase
 {