From d42b3ca57c3137966fe29b8abd79b8bfa65a3d1b Mon Sep 17 00:00:00 2001 From: ksdhans Date: Tue, 14 Jun 2016 18:08:31 +1200 Subject: [PATCH] Fixed RSS feed link for category/tag feeds - The RSS feed link was always the blog's root URL, even for category/tag feeds. FIXED - Changed the return type documented for category() and tag() to include string for the case where an RSS feed is returned (addresses the "Scrutinizer" issues) --- code/model/Blog.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/code/model/Blog.php b/code/model/Blog.php index a32f6d2..c5d3b3b 100644 --- a/code/model/Blog.php +++ b/code/model/Blog.php @@ -826,7 +826,7 @@ class Blog_Controller extends Page_Controller /** * Renders the blog posts for a given tag. * - * @return null|SS_HTTPResponse + * @return null|SS_HTTPResponse|string */ public function tag() { @@ -836,7 +836,7 @@ class Blog_Controller extends Page_Controller $this->blogPosts = $tag->BlogPosts(); if($this->isRSS()) { - return $this->rssFeed($this->blogPosts); + return $this->rssFeed($this->blogPosts, $tag->getLink()); } else { return $this->render(); } @@ -870,7 +870,7 @@ class Blog_Controller extends Page_Controller /** * Renders the blog posts for a given category. * - * @return null|SS_HTTPResponse + * @return null|SS_HTTPResponse|string */ public function category() { @@ -880,7 +880,7 @@ class Blog_Controller extends Page_Controller $this->blogPosts = $category->BlogPosts(); if($this->isRSS()) { - return $this->rssFeed($this->blogPosts); + return $this->rssFeed($this->blogPosts, $category->getLink()); } else { return $this->render(); } @@ -1058,7 +1058,7 @@ class Blog_Controller extends Page_Controller $this->blogPosts = $dataRecord->getBlogPosts(); - return $this->rssFeed($this->blogPosts); + return $this->rssFeed($this->blogPosts, $this->Link()); } /** @@ -1102,11 +1102,14 @@ class Blog_Controller extends Page_Controller /** * Displays an RSS feed of the given blog posts. * + * @param DataList $blogPosts + * @param string $link + * * @return string */ - protected function rssFeed($blogPosts) + protected function rssFeed($blogPosts, $link) { - $rss = new RSSFeed($blogPosts, $this->Link(), $this->MetaTitle, $this->MetaDescription); + $rss = new RSSFeed($blogPosts, $link, $this->MetaTitle, $this->MetaDescription); $this->extend('updateRss', $rss);