]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Feed.php
Merge pull request #4516 from annando/item-ordering
[friendica.git] / src / Protocol / Feed.php
index cc0915472d05cb75ee10aa849cb413abd003eab9..17234ce45af435b9a807561450c9c5e42b6aa329 100644 (file)
@@ -68,6 +68,7 @@ class Feed {
                $xpath->registerNamespace('poco', NAMESPACE_POCO);
 
                $author = [];
+               $entries = null;
 
                // Is it RDF?
                if ($xpath->query('/rdf:RDF/rss:channel')->length > 0) {
@@ -369,9 +370,8 @@ class Feed {
                                $item["title"] = '';
                        }
 
+                       $preview = '';
                        if (!empty($contact["fetch_further_information"]) && ($contact["fetch_further_information"] < 3)) {
-                               $preview = "";
-
                                // Handle enclosures and treat them as preview picture
                                foreach ($attachments AS $attachment) {
                                        if ($attachment["type"] == "image/jpeg") {
@@ -402,7 +402,7 @@ class Feed {
                                // We always strip the title since it will be added in the page information
                                $item["title"] = "";
                                $item["body"] = $item["body"].add_page_info($item["plink"], false, $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_blacklist"]);
-                               $item["tag"] = add_page_keywords($item["plink"], false, $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_blacklist"]);
+                               $item["tag"] = add_page_keywords($item["plink"], $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_blacklist"]);
                                $item["object-type"] = ACTIVITY_OBJ_BOOKMARK;
                                unset($item["attach"]);
                        } else {
@@ -410,12 +410,13 @@ class Feed {
                                        if (!empty($tags)) {
                                                $item["tag"] = $tags;
                                        } else {
-                                               $item["tag"] = add_page_keywords($item["plink"], false, $preview, true, $contact["ffi_keyword_blacklist"]);
+                                               // @todo $preview is never set in this case, is it intended? - @MrPetovan 2018-02-13
+                                               $item["tag"] = add_page_keywords($item["plink"], $preview, true, $contact["ffi_keyword_blacklist"]);
                                        }
                                        $item["body"] .= "\n".$item['tag'];
                                }
                                // Add the link to the original feed entry if not present in feed
-                               if (!strstr($item["body"], $item['plink']) && ($item['plink'] != '')) {
+                               if (($item['plink'] != '') && !strstr($item["body"], $item['plink'])) {
                                        $item["body"] .= "[hr][url]".$item['plink']."[/url]";
                                }
                        }
@@ -423,7 +424,7 @@ class Feed {
                        if (!$simulate) {
                                logger("Stored feed: ".print_r($item, true), LOGGER_DEBUG);
 
-                               $notify = item_is_remote_self($contact, $item);
+                               $notify = Item::isRemoteSelf($contact, $item);
 
                                // Distributed items should have a well formatted URI.
                                // Additionally we have to avoid conflicts with identical URI between imported feeds and these items.
@@ -433,7 +434,7 @@ class Feed {
                                        unset($item['parent-uri']);
                                }
 
-                               $id = item_store($item, false, $notify);
+                               $id = Item::insert($item, false, $notify);
 
                                logger("Feed for contact ".$contact["url"]." stored under id ".$id);
                        } else {