]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
Merge pull request #11895 from annando/smarty-sub-dir
[friendica.git] / src / Model / Item.php
index bd5591ef39ecaddf545c2587d6bc5f3b928b07de..79fe4c02ee6f01da6d1e1b1070051b9ebf944c12 100644 (file)
@@ -196,8 +196,6 @@ class Item
                $notify_items = [];
 
                while ($item = DBA::fetch($items)) {
-                       ActivityPub\PageCache::deleteByUriId($item['uri-id']);
-
                        if (!empty($fields['body'])) {
                                Post\Media::insertFromAttachmentData($item['uri-id'], $fields['body']);
 
@@ -321,8 +319,6 @@ class Item
                // clean up categories and tags so they don't end up as orphans
                Post\Category::deleteByURIId($item['uri-id'], $item['uid']);
 
-               ActivityPub\PageCache::deleteByUriId($item['uri-id']);
-
                /*
                 * If item is a link to a photo resource, nuke all the associated photos
                 * (visitors will not have photo resources)
@@ -705,6 +701,26 @@ class Item
                return 0;
        }
 
+       /**
+        * Fetch the uri-id of the parent for the given uri-id
+        *
+        * @param integer $uriid
+        * @return integer
+        */
+       public static function getParent(int $uriid): int
+       {
+               $thread_parent = Post::selectFirstPost(['thr-parent-id', 'gravity'], ['uri-id' => $uriid]);
+               if (empty($thread_parent)) {
+                       return 0;
+               }
+
+               if ($thread_parent['gravity'] == GRAVITY_PARENT) {
+                       return $uriid;
+               }
+
+               return self::getParent($thread_parent['thr-parent-id']);
+       }
+
        /**
         * Fetch top-level parent data for the given item array
         *