]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
Issue 8735: Ensure the correct data type for "hide"
[friendica.git] / src / Model / Item.php
index cfcf806727b6bc088ff2a93826b95c099753dcc1..7a965f80b5f41649856f47abf2d0866afbf046e5 100644 (file)
@@ -72,14 +72,14 @@ class Item
                'event-id', 'event-created', 'event-edited', 'event-start', 'event-finish',
                'event-summary', 'event-desc', 'event-location', 'event-type',
                'event-nofinish', 'event-adjust', 'event-ignore', 'event-id',
-               'delivery_queue_count', 'delivery_queue_done', 'delivery_queue_failed', 'activity'
+               'delivery_queue_count', 'delivery_queue_done', 'delivery_queue_failed'
        ];
 
        // Field list that is used to deliver items via the protocols
        const DELIVER_FIELDLIST = ['uid', 'id', 'parent', 'uri-id', 'uri', 'thr-parent', 'parent-uri', 'guid',
                        'parent-guid', 'created', 'edited', 'verb', 'object-type', 'object', 'target',
                        'private', 'title', 'body', 'location', 'coord', 'app',
-                       'attach', 'deleted', 'extid', 'post-type',
+                       'attach', 'deleted', 'extid', 'post-type', 'gravity',
                        'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
                        'author-id', 'author-link', 'owner-link', 'contact-uid',
                        'signed_text', 'signature', 'signer', 'network'];
@@ -285,6 +285,10 @@ class Item
                        }
                }
 
+               if (array_key_exists('vid', $row) && is_null($row['vid']) && !empty($row['verb'])) {
+                       $row['vid'] = Verb::getID($row['verb']);
+               }
+                       
                if (!array_key_exists('verb', $row) || in_array($row['verb'], ['', Activity::POST, Activity::SHARE])) {
                        // Build the file string out of the term entries
                        if (array_key_exists('file', $row) && empty($row['file'])) {
@@ -1047,7 +1051,7 @@ class Item
                $fields = ['id', 'uri', 'uri-id', 'uid', 'parent', 'parent-uri', 'origin',
                        'deleted', 'file', 'resource-id', 'event-id', 'attach',
                        'verb', 'object-type', 'object', 'target', 'contact-id',
-                       'icid', 'psid'];
+                       'icid', 'psid', 'gravity'];
                $item = self::selectFirst($fields, ['id' => $item_id]);
                if (!DBA::isResult($item)) {
                        Logger::info('Item not found.', ['id' => $item_id]);
@@ -1066,7 +1070,7 @@ class Item
 
                // clean up categories and tags so they don't end up as orphans
 
-               $matches = false;
+               $matches = [];
                $cnt = preg_match_all('/<(.*?)>/', $item['file'], $matches, PREG_SET_ORDER);
 
                if ($cnt) {
@@ -1075,7 +1079,7 @@ class Item
                        }
                }
 
-               $matches = false;
+               $matches = [];
 
                $cnt = preg_match_all('/\[(.*?)\]/', $item['file'], $matches, PREG_SET_ORDER);
 
@@ -1138,7 +1142,7 @@ class Item
                //}
 
                // If it's the parent of a comment thread, kill all the kids
-               if ($item['id'] == $item['parent']) {
+               if ($item['gravity'] == GRAVITY_PARENT) {
                        self::markForDeletion(['parent' => $item['parent'], 'deleted' => false], $priority);
                }
 
@@ -1494,7 +1498,7 @@ class Item
                                }
                        }
 
-                       $item["parent"]        = $parent['id'];
+                       $item['parent']        = $parent['id'];
                        $item["deleted"]       = $parent['deleted'];
                        $item["allow_cid"]     = $parent['allow_cid'];
                        $item['allow_gid']     = $parent['allow_gid'];
@@ -1529,8 +1533,8 @@ class Item
 
                        // If its a post that originated here then tag the thread as "mention"
                        if ($item['origin'] && $item['uid']) {
-                               DBA::update('thread', ['mention' => true], ['iid' => $item["parent"]]);
-                               Logger::info('tagged thread as mention', ['parent' => $item["parent"], 'uid' => $item['uid']]);
+                               DBA::update('thread', ['mention' => true], ['iid' => $item['parent']]);
+                               Logger::info('tagged thread as mention', ['parent' => $item['parent'], 'uid' => $item['uid']]);
                        }
 
                        // Update the contact relations
@@ -1777,7 +1781,7 @@ class Item
 
                // Check for hashtags in the body and repair or add hashtag links
                self::setHashtags($item);
-               
+
                // Fill the cache field
                self::putInCache($item);
 
@@ -1796,12 +1800,14 @@ class Item
                }
 
                $body = $item['body'];
-               
+
                // We just remove everything that is content
                foreach (array_merge(self::CONTENT_FIELDLIST, self::MIXED_CONTENT_FIELDLIST) as $field) {
                        unset($item[$field]);
                }
 
+               unset($item['activity']);
+
                // Filling item related side tables
 
                // Diaspora signature
@@ -2246,7 +2252,7 @@ class Item
                }
 
                // Is it a toplevel post?
-               if ($item['id'] == $item['parent']) {
+               if ($item['gravity'] == GRAVITY_PARENT) {
                        self::addShadow($itemid);
                        return;
                }
@@ -2544,7 +2550,7 @@ class Item
 
                if (!$mention) {
                        if (($community_page || $prvgroup) &&
-                                 !$item['wall'] && !$item['origin'] && ($item['id'] == $item['parent'])) {
+                                 !$item['wall'] && !$item['origin'] && ($item['gravity'] == GRAVITY_PARENT)) {
                                Logger::info('Delete private group/communiy top-level item without mention', ['id' => $item_id, 'guid'=> $item['guid']]);
                                DBA::delete('item', ['id' => $item_id]);
                                return true;
@@ -2845,7 +2851,7 @@ class Item
                        return;
                }
 
-               $condition = ["`uid` = ? AND NOT `deleted` AND `id` = `parent` AND `gravity` = ?",
+               $condition = ["`uid` = ? AND NOT `deleted` AND `gravity` = ?",
                        $uid, GRAVITY_PARENT];
 
                /*
@@ -3135,7 +3141,7 @@ class Item
        private static function addThread($itemid, $onlyshadow = false)
        {
                $fields = ['uid', 'created', 'edited', 'commented', 'received', 'changed', 'wall', 'private', 'pubmail',
-                       'moderated', 'visible', 'starred', 'contact-id', 'post-type',
+                       'moderated', 'visible', 'starred', 'contact-id', 'post-type', 'uri-id',
                        'deleted', 'origin', 'forum_mode', 'mention', 'network', 'author-id', 'owner-id'];
                $condition = ["`id` = ? AND (`parent` = ? OR `parent` = 0)", $itemid, $itemid];
                $item = self::selectFirst($fields, $condition);
@@ -3156,7 +3162,7 @@ class Item
        private static function updateThread($itemid, $setmention = false)
        {
                $fields = ['uid', 'guid', 'created', 'edited', 'commented', 'received', 'changed', 'post-type',
-                       'wall', 'private', 'pubmail', 'moderated', 'visible', 'starred', 'contact-id',
+                       'wall', 'private', 'pubmail', 'moderated', 'visible', 'starred', 'contact-id', 'uri-id',
                        'deleted', 'origin', 'forum_mode', 'network', 'author-id', 'owner-id'];
                $condition = ["`id` = ? AND (`parent` = ? OR `parent` = 0)", $itemid, $itemid];
 
@@ -3252,9 +3258,9 @@ class Item
                        return DI::l10n()->t('event');
                } elseif (!empty($item['resource-id'])) {
                        return DI::l10n()->t('photo');
-               } elseif (!empty($item['verb']) && $item['verb'] !== Activity::POST) {
+               } elseif ($item['gravity'] == GRAVITY_ACTIVITY) {
                        return DI::l10n()->t('activity');
-               } elseif ($item['id'] != $item['parent']) {
+               } elseif ($item['gravity'] == GRAVITY_COMMENT) {
                        return DI::l10n()->t('comment');
                }