]> git.mxchange.org Git - friendica.git/commitdiff
Replace confusing uses of item.parent-uri with expected item.thr-parent
authorHypolite Petovan <hypolite@mrpetovan.com>
Wed, 11 Nov 2020 07:47:48 +0000 (02:47 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 14 Nov 2020 15:08:50 +0000 (10:08 -0500)
mod/item.php
mod/tagger.php
src/Protocol/DFRN.php
src/Protocol/Diaspora.php
src/Protocol/Feed.php
src/Protocol/OStatus.php
src/Worker/OnePoll.php

index 9828d1acb28d40984bcb2eaa97d27e50f7c901bf..3869ea9107e02ae6cb0f6e027efe5872e80c4944 100644 (file)
@@ -605,8 +605,7 @@ function item_post(App $a) {
        $datarray['pubmail']       = $pubmail_enabled;
        $datarray['attach']        = $attachments;
 
-       // This is not a bug. The item store function changes 'parent-uri' to 'thr-parent' and fetches 'parent-uri' new. (We should change this)
-       $datarray['parent-uri']    = $thr_parent_uri;
+       $datarray['thr-parent']    = $thr_parent_uri;
 
        $datarray['postopts']      = $postopts;
        $datarray['origin']        = $origin;
@@ -627,7 +626,7 @@ function item_post(App $a) {
        // This field is for storing the raw conversation data
        $datarray['protocol'] = Conversation::PARCEL_DFRN;
 
-       $conversation = DBA::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $datarray['parent-uri']]);
+       $conversation = DBA::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $datarray['thr-parent']]);
        if (DBA::isResult($conversation)) {
                if ($conversation['conversation-uri'] != '') {
                        $datarray['conversation-uri'] = $conversation['conversation-uri'];
index 86a6ff69f302c3d97ea1b2100716a7e417e43e90..63e7f2ca80d490ca0357d0f3eeb4d2c75ca35ef8 100644 (file)
@@ -136,7 +136,7 @@ EOT;
        $arr['wall'] = $item['wall'];
        $arr['gravity'] = GRAVITY_COMMENT;
        $arr['parent'] = $item['id'];
-       $arr['parent-uri'] = $item['uri'];
+       $arr['thr-parent'] = $item['uri'];
        $arr['owner-name'] = $item['author-name'];
        $arr['owner-link'] = $item['author-link'];
        $arr['owner-avatar'] = $item['author-avatar'];
index 11c4e3a14d3810f98b2478c13582819cf3b5edf3..165a63c7cbcd9531f862ee596ec952e509603f1f 100644 (file)
@@ -438,7 +438,7 @@ class DFRN
                $mail->appendChild($sender);
 
                XML::addElement($doc, $mail, "dfrn:id", $item['uri']);
-               XML::addElement($doc, $mail, "dfrn:in-reply-to", $item['parent-uri']);
+               XML::addElement($doc, $mail, "dfrn:in-reply-to", $item['thr-parent']);
                XML::addElement($doc, $mail, "dfrn:sentdate", DateTimeFormat::utc($item['created'] . '+00:00', DateTimeFormat::ATOM));
                XML::addElement($doc, $mail, "dfrn:subject", $item['title']);
                XML::addElement($doc, $mail, "dfrn:content", $item['body']);
@@ -956,10 +956,9 @@ class DFRN
                $entry->appendChild($dfrnowner);
 
                if ($item['gravity'] != GRAVITY_PARENT) {
-                       $parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
-                       $parent = Item::selectFirst(['guid', 'plink'], ['uri' => $parent_item, 'uid' => $item['uid']]);
+                       $parent = Item::selectFirst(['guid', 'plink'], ['uri' => $item['thr-parent'], 'uid' => $item['uid']]);
                        if (DBA::isResult($parent)) {
-                               $attributes = ["ref" => $parent_item, "type" => "text/html",
+                               $attributes = ["ref" => $item['thr-parent'], "type" => "text/html",
                                        "href" => $parent['plink'],
                                        "dfrn:diaspora_guid" => $parent['guid']];
                                XML::addElement($doc, $entry, "thr:in-reply-to", "", $attributes);
@@ -971,7 +970,7 @@ class DFRN
                $conversation_uri = $conversation_href;
 
                if (isset($parent_item)) {
-                       $conversation = DBA::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $item['parent-uri']]);
+                       $conversation = DBA::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $item['thr-parent']]);
                        if (DBA::isResult($conversation)) {
                                if ($conversation['conversation-uri'] != '') {
                                        $conversation_uri = $conversation['conversation-uri'];
@@ -1768,7 +1767,7 @@ class DFRN
                $msg["from-photo"] = XML::getFirstValue($xpath, "dfrn:sender/dfrn:avatar/text()", $mail);
                $msg["contact-id"] = $importer["id"];
                $msg["uri"] = XML::getFirstValue($xpath, "dfrn:id/text()", $mail);
-               $msg["parent-uri"] = XML::getFirstValue($xpath, "dfrn:in-reply-to/text()", $mail);
+               $msg["thr-parent"] = XML::getFirstValue($xpath, "dfrn:in-reply-to/text()", $mail);
                $msg["created"] = DateTimeFormat::utc(XML::getFirstValue($xpath, "dfrn:sentdate/text()", $mail));
                $msg["title"] = XML::getFirstValue($xpath, "dfrn:subject/text()", $mail);
                $msg["body"] = XML::getFirstValue($xpath, "dfrn:content/text()", $mail);
@@ -1918,7 +1917,7 @@ class DFRN
         */
        private static function getEntryType($importer, $item)
        {
-               if ($item["parent-uri"] != $item["uri"]) {
+               if ($item["thr-parent"] != $item["uri"]) {
                        $community = false;
 
                        if ($importer["page-flags"] == User::PAGE_FLAGS_COMMUNITY || $importer["page-flags"] == User::PAGE_FLAGS_PRVGROUP) {
@@ -1934,18 +1933,18 @@ class DFRN
 
                        $is_a_remote_action = false;
 
-                       $parent = Item::selectFirst(['parent-uri'], ['uri' => $item["parent-uri"]]);
+                       $parent = Item::selectFirst(['thr-parent'], ['uri' => $item["thr-parent"]]);
                        if (DBA::isResult($parent)) {
                                $r = q(
                                        "SELECT `item`.`forum_mode`, `item`.`wall` FROM `item`
                                        INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
-                                       WHERE `item`.`uri` = '%s' AND (`item`.`parent-uri` = '%s' OR `item`.`thr-parent` = '%s')
+                                       WHERE `item`.`uri` = '%s' AND (`item`.`thr-parent` = '%s' OR `item`.`thr-parent` = '%s')
                                        AND `item`.`uid` = %d
                                        $sql_extra
                                        LIMIT 1",
-                                       DBA::escape($parent["parent-uri"]),
-                                       DBA::escape($parent["parent-uri"]),
-                                       DBA::escape($parent["parent-uri"]),
+                                       DBA::escape($parent["thr-parent"]),
+                                       DBA::escape($parent["thr-parent"]),
+                                       DBA::escape($parent["thr-parent"]),
                                        intval($importer["importer_uid"])
                                );
                                if (DBA::isResult($r)) {
@@ -2008,7 +2007,7 @@ class DFRN
                        if ($Blink && Strings::compareLink($Blink, DI::baseUrl() . "/profile/" . $importer["nickname"])) {
                                $author = DBA::selectFirst('contact', ['name', 'thumb', 'url'], ['id' => $item['author-id']]);
 
-                               $parent = Item::selectFirst(['id'], ['uri' => $item['parent-uri'], 'uid' => $importer["importer_uid"]]);
+                               $parent = Item::selectFirst(['id'], ['uri' => $item['thr-parent'], 'uid' => $importer["importer_uid"]]);
                                $item['parent'] = $parent['id'];
 
                                // send a notification
@@ -2090,15 +2089,15 @@ class DFRN
                                $is_like = true;
                                $item["gravity"] = GRAVITY_ACTIVITY;
                                // only one like or dislike per person
-                               // splitted into two queries for performance issues
+                               // split into two queries for performance issues
                                $condition = ['uid' => $item["uid"], 'author-id' => $item["author-id"], 'gravity' => GRAVITY_ACTIVITY,
-                                       'verb' => $item["verb"], 'parent-uri' => $item["parent-uri"]];
+                                       'verb' => $item['verb'], 'parent-uri' => $item['thr-parent']];
                                if (Item::exists($condition)) {
                                        return false;
                                }
 
                                $condition = ['uid' => $item["uid"], 'author-id' => $item["author-id"], 'gravity' => GRAVITY_ACTIVITY,
-                                       'verb' => $item["verb"], 'thr-parent' => $item["parent-uri"]];
+                                       'verb' => $item['verb'], 'thr-parent' => $item['thr-parent']];
                                if (Item::exists($condition)) {
                                        return false;
                                }
@@ -2370,19 +2369,19 @@ class DFRN
                }
 
                // Is it a reply or a top level posting?
-               $item["parent-uri"] = $item["uri"];
+               $item['thr-parent'] = $item['uri'];
 
                $inreplyto = $xpath->query("thr:in-reply-to", $entry);
                if (is_object($inreplyto->item(0))) {
                        foreach ($inreplyto->item(0)->attributes as $attributes) {
                                if ($attributes->name == "ref") {
-                                       $item["parent-uri"] = $attributes->textContent;
+                                       $item['thr-parent'] = $attributes->textContent;
                                }
                        }
                }
 
                // Check if the message is wanted
-               if (($importer["importer_uid"] == 0) && ($item['uri'] == $item['parent-uri'])) {
+               if (($importer['importer_uid'] == 0) && ($item['uri'] == $item['thr-parent'])) {
                        if (!self::isSolicitedMessage($item)) {
                                DBA::delete('item-uri', ['uri' => $item['uri']]);
                                return 403;
@@ -2760,7 +2759,7 @@ class DFRN
 
                // check that the message originated elsewhere and is a top-level post
 
-               if ($item['wall'] || $item['origin'] || ($item['uri'] != $item['parent-uri'])) {
+               if ($item['wall'] || $item['origin'] || ($item['uri'] != $item['thr-parent'])) {
                        return false;
                }
 
index 8c93d7c0f26ffd664e31ad87bb48b9da52c3b2ad..04d076c03a44ac62a7d1df0d3e9e926fef5ff033 100644 (file)
@@ -1697,9 +1697,9 @@ class Diaspora
 
                if (isset($data->thread_parent_guid)) {
                        $thread_parent_guid = Strings::escapeTags(XML::unescape($data->thread_parent_guid));
-                       $thr_uri = self::getUriFromGuid("", $thread_parent_guid, true);
+                       $thr_parent = self::getUriFromGuid("", $thread_parent_guid, true);
                } else {
-                       $thr_uri = "";
+                       $thr_parent = "";
                }
 
                $contact = self::allowedContactByHandle($importer, $sender, true);
@@ -1712,8 +1712,8 @@ class Diaspora
                        return true;
                }
 
-               $parent_item = self::parentItem($importer["uid"], $parent_guid, $author, $contact);
-               if (!$parent_item) {
+               $toplevel_parent_item = self::parentItem($importer["uid"], $parent_guid, $author, $contact);
+               if (!$toplevel_parent_item) {
                        return false;
                }
 
@@ -1754,11 +1754,8 @@ class Diaspora
                $datarray["verb"] = Activity::POST;
                $datarray["gravity"] = GRAVITY_COMMENT;
 
-               if ($thr_uri != "") {
-                       $datarray["parent-uri"] = $thr_uri;
-               } else {
-                       $datarray["parent-uri"] = $parent_item["uri"];
-               }
+               $datarray['thr-parent'] = $thr_parent ?: $toplevel_parent_item['uri'];
+               $datarray['parent-uri'] = $toplevel_parent_item['uri'];
 
                $datarray["object-type"] = Activity\ObjectType::COMMENT;
 
@@ -1767,7 +1764,7 @@ class Diaspora
 
                $datarray["changed"] = $datarray["created"] = $datarray["edited"] = $created_at;
 
-               $datarray["plink"] = self::plink($author, $guid, $parent_item['guid']);
+               $datarray["plink"] = self::plink($author, $guid, $toplevel_parent_item['guid']);
                $body = Markdown::toBBCode($text);
 
                $datarray["body"] = self::replacePeopleGuid($body, $person["url"]);
@@ -1779,7 +1776,7 @@ class Diaspora
 
                // If we are the origin of the parent we store the original data.
                // We notify our followers during the item storage.
-               if ($parent_item["origin"]) {
+               if ($toplevel_parent_item["origin"]) {
                        $datarray['diaspora_signed_text'] = json_encode($data);
                }
 
@@ -1953,8 +1950,8 @@ class Diaspora
                        return true;
                }
 
-               $parent_item = self::parentItem($importer["uid"], $parent_guid, $author, $contact);
-               if (!$parent_item) {
+               $toplevel_parent_item = self::parentItem($importer["uid"], $parent_guid, $author, $contact);
+               if (!$toplevel_parent_item) {
                        return false;
                }
 
@@ -1991,7 +1988,7 @@ class Diaspora
 
                $datarray["verb"] = $verb;
                $datarray["gravity"] = GRAVITY_ACTIVITY;
-               $datarray["parent-uri"] = $parent_item["uri"];
+               $datarray['thr-parent'] = $toplevel_parent_item['uri'];
 
                $datarray["object-type"] = Activity\ObjectType::NOTE;
 
@@ -2001,11 +1998,11 @@ class Diaspora
                $datarray["changed"] = $datarray["created"] = $datarray["edited"] = DateTimeFormat::utcNow();
 
                // like on comments have the comment as parent. So we need to fetch the toplevel parent
-               if ($parent_item['gravity'] != GRAVITY_PARENT) {
-                       $toplevel = Item::selectFirst(['origin'], ['id' => $parent_item['parent']]);
+               if ($toplevel_parent_item['gravity'] != GRAVITY_PARENT) {
+                       $toplevel = Item::selectFirst(['origin'], ['id' => $toplevel_parent_item['parent']]);
                        $origin = $toplevel["origin"];
                } else {
-                       $origin = $parent_item["origin"];
+                       $origin = $toplevel_parent_item["origin"];
                }
 
                // If we are the origin of the parent we store the original data.
@@ -2116,16 +2113,16 @@ class Diaspora
                        return true;
                }
 
-               $parent_item = self::parentItem($importer["uid"], $parent_guid, $author, $contact);
-               if (!$parent_item) {
+               $toplevel_parent_item = self::parentItem($importer["uid"], $parent_guid, $author, $contact);
+               if (!$toplevel_parent_item) {
                        return false;
                }
 
-               if (!$parent_item['origin']) {
+               if (!$toplevel_parent_item['origin']) {
                        Logger::info('Not our origin. Participation is ignored', ['parent_guid' => $parent_guid, 'guid' => $guid, 'author' => $author]);
                }
 
-               if (!in_array($parent_item['private'], [Item::PUBLIC, Item::UNLISTED])) {
+               if (!in_array($toplevel_parent_item['private'], [Item::PUBLIC, Item::UNLISTED])) {
                        Logger::info('Item is not public, participation is ignored', ['parent_guid' => $parent_guid, 'guid' => $guid, 'author' => $author]);
                        return false;
                }
@@ -2155,7 +2152,8 @@ class Diaspora
 
                $datarray["verb"] = Activity::FOLLOW;
                $datarray["gravity"] = GRAVITY_ACTIVITY;
-               $datarray["parent-uri"] = $parent_item["uri"];
+               $datarray['thr-parent'] = $toplevel_parent_item['uri'];
+               $datarray['parent-uri'] = $toplevel_parent_item['parent-uri'];
 
                $datarray["object-type"] = Activity\ObjectType::NOTE;
 
@@ -2170,7 +2168,7 @@ class Diaspora
 
                // Send all existing comments and likes to the requesting server
                $comments = Item::select(['id', 'uri-id', 'parent-author-network', 'author-network', 'verb'],
-                       ['parent' => $parent_item['id'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_ACTIVITY]]);
+                       ['parent' => $toplevel_parent_item['id'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_ACTIVITY]]);
                while ($comment = Item::fetch($comments)) {
                        if (in_array($comment['verb'], [Activity::FOLLOW, Activity::TAG])) {
                                Logger::info('participation messages are not relayed', ['item' => $comment['id']]);
@@ -2547,7 +2545,8 @@ class Diaspora
 
                $datarray['guid'] = $parent['guid'] . '-' . $guid;
                $datarray['uri'] = self::getUriFromGuid($author, $datarray['guid']);
-               $datarray['parent-uri'] = $parent['uri'];
+               $datarray['thr-parent'] = $parent['uri'];
+               $datarray['parent-uri'] = $parent['parent-uri'];
 
                $datarray['verb'] = $datarray['body'] = Activity::ANNOUNCE;
                $datarray['gravity'] = GRAVITY_ACTIVITY;
@@ -2618,7 +2617,7 @@ class Diaspora
                $datarray["owner-id"] = $datarray["author-id"];
 
                $datarray["guid"] = $guid;
-               $datarray["uri"] = $datarray["parent-uri"] = self::getUriFromGuid($author, $guid);
+               $datarray["uri"] = $datarray["thr-parent"] = self::getUriFromGuid($author, $guid);
                $datarray['uri-id'] = ItemURI::insert(['uri' => $datarray['uri'], 'guid' => $datarray['guid']]);
 
                $datarray["verb"] = Activity::POST;
@@ -2703,7 +2702,7 @@ class Diaspora
                }
 
                // Fetch items that are about to be deleted
-               $fields = ['uid', 'id', 'parent', 'parent-uri', 'author-link', 'file'];
+               $fields = ['uid', 'id', 'parent', 'author-link', 'file'];
 
                // When we receive a public retraction, we delete every item that we find.
                if ($importer['uid'] == 0) {
@@ -2872,7 +2871,7 @@ class Diaspora
                $datarray = [];
 
                $datarray["guid"] = $guid;
-               $datarray["uri"] = $datarray["parent-uri"] = self::getUriFromGuid($author, $guid);
+               $datarray["uri"] = $datarray["thr-parent"] = self::getUriFromGuid($author, $guid);
                $datarray['uri-id'] = ItemURI::insert(['uri' => $datarray['uri'], 'guid' => $datarray['guid']]);
 
                // Attach embedded pictures to the body
@@ -3681,12 +3680,12 @@ class Diaspora
         */
        private static function constructLike(array $item, array $owner)
        {
-               $parent = Item::selectFirst(['guid', 'uri', 'parent-uri'], ['uri' => $item["thr-parent"]]);
+               $parent = Item::selectFirst(['guid', 'uri', 'thr-parent'], ['uri' => $item["thr-parent"]]);
                if (!DBA::isResult($parent)) {
                        return false;
                }
 
-               $target_type = ($parent["uri"] === $parent["parent-uri"] ? "Post" : "Comment");
+               $target_type = ($parent["uri"] === $parent["thr-parent"] ? "Post" : "Comment");
                $positive = null;
                if ($item['verb'] === Activity::LIKE) {
                        $positive = "true";
@@ -3713,7 +3712,7 @@ class Diaspora
         */
        private static function constructAttend(array $item, array $owner)
        {
-               $parent = Item::selectFirst(['guid', 'uri', 'parent-uri'], ['uri' => $item["thr-parent"]]);
+               $parent = Item::selectFirst(['guid'], ['uri' => $item['thr-parent']]);
                if (!DBA::isResult($parent)) {
                        return false;
                }
@@ -4242,10 +4241,7 @@ class Diaspora
                        return false;
                }
 
-               // This is a workaround for the behaviour of the "insert" function, see mod/item.php
-               $item['thr-parent'] = $item['parent-uri'];
-
-               $parent = Item::selectFirst(['parent-uri'], ['uri' => $item['parent-uri']]);
+               $parent = Item::selectFirst(['parent-uri'], ['uri' => $item['thr-parent']]);
                if (!DBA::isResult($parent)) {
                        return;
                }
index fee765f25b943183f5f93b6b9eb77c2722ba05b2..c7d19a996dece346e76d6948af1c221cf5872600 100644 (file)
@@ -354,7 +354,7 @@ class Feed
 
                        $item["plink"] = DI::httpRequest()->finalUrl($item["plink"]);
 
-                       $item["parent-uri"] = $item["uri"];
+                       $item["thr-parent"] = $item["uri"];
 
                        $item["title"] = XML::getFirstNodeValue($xpath, 'atom:title/text()', $entry);
 
@@ -602,6 +602,7 @@ class Feed
                        if ($notify) {
                                $item['guid'] = Item::guidFromUri($orig_plink, DI::baseUrl()->getHostname());
                                unset($item['uri']);
+                               unset($item['thr-parent']);
                                unset($item['parent-uri']);
 
                                // Set the delivery priority for "remote self" to "medium"
@@ -1108,9 +1109,8 @@ class Feed
 
                if ($item['gravity'] != GRAVITY_PARENT) {
                        $parent = Item::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
-                       $parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
 
-                       $thrparent = Item::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner["uid"], 'uri' => $parent_item]);
+                       $thrparent = Item::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner["uid"], 'uri' => $item['thr-parent']]);
 
                        if (DBA::isResult($thrparent)) {
                                $mentioned[$thrparent["author-link"]] = $thrparent["author-link"];
@@ -1123,7 +1123,7 @@ class Feed
                        }
 
                        $attributes = [
-                                       "ref" => $parent_item,
+                                       "ref" => $item['thr-parent'],
                                        "href" => $parent_plink];
                        XML::addElement($doc, $entry, "thr:in-reply-to", "", $attributes);
 
index e394877b354d85319d8e9f902d1720a5a8a3a15a..9218f266510ba97ad325f7a69143928daf824749 100644 (file)
@@ -482,7 +482,7 @@ class OStatus
                                Logger::log("Favorite ".$orig_uri." ".print_r($item, true));
 
                                $item["verb"] = Activity::LIKE;
-                               $item["parent-uri"] = $orig_uri;
+                               $item["thr-parent"] = $orig_uri;
                                $item["gravity"] = GRAVITY_ACTIVITY;
                                $item["object-type"] = Activity\ObjectType::NOTE;
                        }
@@ -495,7 +495,7 @@ class OStatus
                        self::processPost($xpath, $entry, $item, $importer);
 
                        if ($initialize && (count(self::$itemlist) > 0)) {
-                               if (self::$itemlist[0]['uri'] == self::$itemlist[0]['parent-uri']) {
+                               if (self::$itemlist[0]['uri'] == self::$itemlist[0]['thr-parent']) {
                                        // We will import it everytime, when it is started by our contacts
                                        $valid = Contact::isSharingByURL(self::$itemlist[0]['author-link'], self::$itemlist[0]['uid']);
 
@@ -523,9 +523,9 @@ class OStatus
                                        }
                                } else {
                                        // But we will only import complete threads
-                                       $valid = Item::exists(['uid' => $importer["uid"], 'uri' => self::$itemlist[0]['parent-uri']]);
+                                       $valid = Item::exists(['uid' => $importer["uid"], 'uri' => self::$itemlist[0]['thr-parent']]);
                                        if ($valid) {
-                                               Logger::log("Item with uri ".self::$itemlist[0]["uri"]." belongs to parent ".self::$itemlist[0]['parent-uri']." of user ".$importer["uid"].". It will be imported.", Logger::DEBUG);
+                                               Logger::log("Item with uri ".self::$itemlist[0]["uri"]." belongs to parent ".self::$itemlist[0]['thr-parent']." of user ".$importer["uid"].". It will be imported.", Logger::DEBUG);
                                        }
                                }
 
@@ -621,7 +621,7 @@ class OStatus
                if (is_object($inreplyto->item(0))) {
                        foreach ($inreplyto->item(0)->attributes as $attributes) {
                                if ($attributes->name == "ref") {
-                                       $item["parent-uri"] = $attributes->textContent;
+                                       $item["thr-parent"] = $attributes->textContent;
                                }
                                if ($attributes->name == "href") {
                                        $related = $attributes->textContent;
@@ -702,16 +702,16 @@ class OStatus
                        self::fetchConversation($item['conversation-href'], $item['conversation-uri']);
                }
 
-               if (isset($item["parent-uri"])) {
-                       if (!Item::exists(['uid' => $importer["uid"], 'uri' => $item['parent-uri']])) {
+               if (isset($item["thr-parent"])) {
+                       if (!Item::exists(['uid' => $importer["uid"], 'uri' => $item['thr-parent']])) {
                                if ($related != '') {
-                                       self::fetchRelated($related, $item["parent-uri"], $importer);
+                                       self::fetchRelated($related, $item["thr-parent"], $importer);
                                }
                        } else {
                                Logger::log('Reply with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', Logger::DEBUG);
                        }
                } else {
-                       $item["parent-uri"] = $item["uri"];
+                       $item["thr-parent"] = $item["uri"];
                        $item["gravity"] = GRAVITY_PARENT;
                }
 
@@ -1074,7 +1074,7 @@ class OStatus
                if (is_object($inreplyto->item(0))) {
                        foreach ($inreplyto->item(0)->attributes as $attributes) {
                                if ($attributes->name == "ref") {
-                                       $item["parent-uri"] = $attributes->textContent;
+                                       $item["thr-parent"] = $attributes->textContent;
                                }
                        }
                }
@@ -1126,8 +1126,8 @@ class OStatus
                                                break;
                                        case "related":
                                                if ($item["object-type"] != Activity\ObjectType::BOOKMARK) {
-                                                       if (!isset($item["parent-uri"])) {
-                                                               $item["parent-uri"] = $attribute['href'];
+                                                       if (!isset($item["thr-parent"])) {
+                                                               $item["thr-parent"] = $attribute['href'];
                                                        }
                                                        $link_data['related'] = $attribute['href'];
                                                } else {
@@ -1934,9 +1934,8 @@ class OStatus
 
                if ($item['gravity'] != GRAVITY_PARENT) {
                        $parent = Item::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
-                       $parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
 
-                       $thrparent = Item::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner["uid"], 'uri' => $parent_item]);
+                       $thrparent = Item::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner["uid"], 'uri' => $item['thr-parent']]);
 
                        if (DBA::isResult($thrparent)) {
                                $mentioned[$thrparent["author-link"]] = $thrparent["author-link"];
@@ -1949,7 +1948,7 @@ class OStatus
                        }
 
                        $attributes = [
-                                       "ref" => $parent_item,
+                                       "ref" => $item['thr-parent'],
                                        "href" => $parent_plink];
                        XML::addElement($doc, $entry, "thr:in-reply-to", "", $attributes);
 
@@ -1960,7 +1959,7 @@ class OStatus
                }
 
                if (intval($item['parent']) > 0) {
-                       $conversation_href = $conversation_uri = str_replace('/objects/', '/context/', $item['parent-uri']);
+                       $conversation_href = $conversation_uri = str_replace('/objects/', '/context/', $item['thr-parent']);
 
                        if (isset($parent_item)) {
                                $conversation = DBA::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $parent_item]);
index 8f1e94580bb2d544ab92c3166ab29cf931738e78..bdef1ac4d29727486151d31beae58a2201389d57 100644 (file)
@@ -622,8 +622,8 @@ class OnePoll
                                                }
                                        }
 
-                                       if (empty($datarray['parent-uri'])) {
-                                               $datarray['parent-uri'] = $datarray['uri'];
+                                       if (!empty($datarray['parent-uri'])) {
+                                               $datarray['thr-parent'] = $datarray['parent-uri'];
                                        }
                                        unset($datarray['parent-uri']);
 
@@ -664,7 +664,7 @@ class OnePoll
                                        $datarray['owner-link'] = "mailto:".$contact['addr'];
                                        $datarray['owner-avatar'] = $contact['photo'];
 
-                                       if ($datarray['parent-uri'] === $datarray['uri']) {
+                                       if ($datarray['thr-parent'] === $datarray['uri']) {
                                                $datarray['private'] = Item::PRIVATE;
                                        }