]> git.mxchange.org Git - friendica.git/commitdiff
Added logging, fixed indentation, call it from DFRN as well
authorMichael <heluecht@pirati.ca>
Thu, 5 Dec 2019 05:28:28 +0000 (05:28 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 5 Dec 2019 05:28:28 +0000 (05:28 +0000)
src/Model/Item.php
src/Protocol/DFRN.php

index 5309a898bc9695dd90157479791981e469317865..0f008518b0410b3d70865d1d3ce404d5e56ba82e 100644 (file)
@@ -3778,10 +3778,10 @@ class Item extends BaseObject
 
                $attribute_string = $matches[2];
                $attributes = ['comment' => trim($matches[1]), 'shared' => trim($matches[3])];
-               foreach(['author', 'profile', 'avatar', 'guid', 'posted', 'link'] as $field) {
-                               if (preg_match("/$field=(['\"])(.+?)\\1/ism", $attribute_string, $matches)) {
-                                       $attributes[$field] = trim(html_entity_decode($matches[2] ?? '', ENT_QUOTES, 'UTF-8'));
-                               }
+               foreach (['author', 'profile', 'avatar', 'guid', 'posted', 'link'] as $field) {
+                       if (preg_match("/$field=(['\"])(.+?)\\1/ism", $attribute_string, $matches)) {
+                               $attributes[$field] = trim(html_entity_decode($matches[2] ?? '', ENT_QUOTES, 'UTF-8'));
+                       }
                }
                return $attributes;
        }
@@ -3813,6 +3813,7 @@ class Item extends BaseObject
                        // Otherwhise try to find (and possibly fetch) the item via the link. This should work for Diaspora and ActivityPub posts
                        $id = self::fetchByLink($shared['link'], $uid);
                        if (empty($id)) {
+                               Logger::info('Original item not found', ['url' => $shared['link'], 'callstack' => System::callstack()]);
                                return $item;
                        }
 
@@ -3820,6 +3821,9 @@ class Item extends BaseObject
                        if (!DBA::isResult($shared_item)) {
                                return $item;
                        }
+                       Logger::info('Got shared data from url', ['url' => $shared['link'], 'callstack' => System::callstack()]);
+               } else {
+                       Logger::info('Got shared data from guid', ['guid' => $shared['guid'], 'callstack' => System::callstack()]);
                }
 
                if (!empty($shared_item['title'])) {
index 0b6e02f096118ad37e98076193262a9a9ea59515..f7a8f693902e37591cc4b72b0f2c99440f4a1c19 100644 (file)
@@ -2537,6 +2537,9 @@ class DFRN
                        }
                }
 
+               // Ensure to have the correct share data
+               $item = Item::addShareDataFromOriginal($item);
+
                if ($entrytype == DFRN::REPLY_RC) {
                        $item["wall"] = 1;
                } elseif ($entrytype == DFRN::TOP_LEVEL) {