From 3821ca9737eeafe6ef69ab57d980c233e6b2a00c Mon Sep 17 00:00:00 2001 From: boyska Date: Mon, 10 Sep 2018 23:57:43 +0200 Subject: [PATCH] [Facebook] make guids really permanent Some facebook tracking query parameter was getting inside the and tags. This commit strips them off so that a feed reader won't think there are always new posts. --- bridges/FacebookBridge.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bridges/FacebookBridge.php b/bridges/FacebookBridge.php index c8ea0d7..8835020 100644 --- a/bridges/FacebookBridge.php +++ b/bridges/FacebookBridge.php @@ -165,6 +165,14 @@ class FacebookBridge extends BridgeAbstract { return htmlspecialchars_decode($ogtitle->content, ENT_QUOTES); } + private function uri_strip_args($uri) { + $clean = strtok($uri, '?'); + if($clean === FALSE) { + return $uri; + } else { + return $clean; + } + } private function extractGroupURI($post) { @@ -175,7 +183,7 @@ class FacebookBridge extends BridgeAbstract { // Find the one that is a permalink if(strpos($anchor->href, 'permalink') !== false) { - return $anchor->href; + return $this->uri_strip_args($anchor->href); } } @@ -539,7 +547,7 @@ EOD; $uri = self::URI . $post->find('abbr')[0]->parent()->getAttribute('href'); //Build and add final item - $item['uri'] = htmlspecialchars_decode($uri); + $item['uri'] = $this->uri_strip_args(htmlspecialchars_decode($uri)); $item['content'] = htmlspecialchars_decode($content); $item['title'] = $title; $item['author'] = $author;