saper has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/247821

Change subject: Advertise feeds only if $wgFeed is enabled
......................................................................

Advertise feeds only if $wgFeed is enabled

Wikis with $wgFeed=false should not present
an Atom icon on the RecentChanges/Watchlist.

Additionally do not require $wgFeed=true
in order to use $wgOverrideSiteFeed.
Wikis that use an external feed (from
some blog, news site, etc.) may want
to completely disable MediaWiki built-in
feed feature.

Change-Id: Ic64f7f5115a77c42ed2b336f6996fe711b3822ba
---
M RELEASE-NOTES-1.27
M includes/OutputPage.php
2 files changed, 57 insertions(+), 42 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/21/247821/1

diff --git a/RELEASE-NOTES-1.27 b/RELEASE-NOTES-1.27
index 7d4ac3d..bbb067d 100644
--- a/RELEASE-NOTES-1.27
+++ b/RELEASE-NOTES-1.27
@@ -45,6 +45,7 @@
    creation of passwordless "system" users for logged actions.
 * $wgMaxSquidPurgeTitles was removed.
 * $wgAjaxWatch was removed. This is now enabled by default.
+* (T116145) Enabling $wgFeed is no longer required to use $wgOverrideSiteFeed 
feature.
 
 === New features in 1.27 ===
 * $wgDataCenterId and $wgDataCenterRoles where added, which will serve as
@@ -67,6 +68,7 @@
 ==== External libraries ====
 
 === Bug fixes in 1.27 ===
+* (T116145) RSS/Atom feeds are no longer advertised if $wgFeed is disabled.
 
 === Action API changes in 1.27 ===
 * Added list=allrevisions.
diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index d29ec54..00fc7b6 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -1151,6 +1151,20 @@
        }
 
        /**
+        * Return effective list of advertised feed types
+        * @see addFeedLink()
+        *
+        * @return array Array of feed type names ( 'rss', 'atom' )
+        */
+       protected function getAdvertisedFeedTypes() {
+               if ( $this->getConfig()->get( 'Feed' ) ) {
+                       return $this->getConfig()->get( 'AdvertisedFeedTypes' 
); 
+               } else {
+                       return array();
+               }
+       }
+
+       /**
         * Add or remove feed links in the page header
         * This is mainly kept for backward compatibility, see 
OutputPage::addFeedLink()
         * for the new version
@@ -1178,7 +1192,7 @@
        public function setFeedAppendQuery( $val ) {
                $this->mFeedLinks = array();
 
-               foreach ( $this->getConfig()->get( 'AdvertisedFeedTypes' ) as 
$type ) {
+               foreach ( $this->getAdvertisedFeedTypes() as $type ) {
                        $query = "feed=$type";
                        if ( is_string( $val ) ) {
                                $query .= '&' . $val;
@@ -1194,7 +1208,7 @@
         * @param string $href URL
         */
        public function addFeedLink( $format, $href ) {
-               if ( in_array( $format, $this->getConfig()->get( 
'AdvertisedFeedTypes' ) ) ) {
+               if ( in_array( $format, $this->getAdvertisedFeedTypes() ) ) {
                        $this->mFeedLinks[$format] = $href;
                }
        }
@@ -3512,50 +3526,49 @@
                }
 
                # Feeds
-               if ( $config->get( 'Feed' ) ) {
-                       foreach ( $this->getSyndicationLinks() as $format => 
$link ) {
-                               # Use the page name for the title.  In 
principle, this could
-                               # lead to issues with having the same name for 
different feeds
-                               # corresponding to the same page, but we can't 
avoid that at
-                               # this low a level.
+               foreach ( $this->getSyndicationLinks() as $format => $link ) {
+                       # Use the page name for the title.  In principle, this 
could
+                       # lead to issues with having the same name for 
different feeds
+                       # corresponding to the same page, but we can't avoid 
that at
+                       # this low a level.
+                       # Empty if $wgFeed is false.
 
+                       $tags[] = $this->feedLink(
+                               $format,
+                               $link,
+                               # Used messages: 'page-rss-feed' and 
'page-atom-feed' (for an easier grep)
+                               $this->msg(
+                                       "page-{$format}-feed", 
$this->getTitle()->getPrefixedText()
+                               )->text()
+                       );
+               }
+
+               # Recent changes feed should appear on every page (except 
recentchanges,
+               # that would be redundant). Put it after the per-page feed to 
avoid
+               # changing existing behavior. It's still available, probably 
via a
+               # menu in your browser. Some sites might have a different feed 
they'd
+               # like to promote instead of the RC feed (maybe like a "Recent 
New Articles"
+               # or "Breaking news" one). For this, we see if 
$wgOverrideSiteFeed is defined.
+               # If so, use it instead.
+               $sitename = $config->get( 'Sitename' );
+               if ( $config->get( 'OverrideSiteFeed' ) ) {
+                       foreach ( $config->get( 'OverrideSiteFeed' ) as $type 
=> $feedUrl ) {
+                               // Note, this->feedLink escapes the url.
                                $tags[] = $this->feedLink(
-                                       $format,
-                                       $link,
-                                       # Used messages: 'page-rss-feed' and 
'page-atom-feed' (for an easier grep)
-                                       $this->msg(
-                                               "page-{$format}-feed", 
$this->getTitle()->getPrefixedText()
-                                       )->text()
+                                       $type,
+                                       $feedUrl,
+                                       $this->msg( "site-{$type}-feed", 
$sitename )->text()
                                );
                        }
-
-                       # Recent changes feed should appear on every page 
(except recentchanges,
-                       # that would be redundant). Put it after the per-page 
feed to avoid
-                       # changing existing behavior. It's still available, 
probably via a
-                       # menu in your browser. Some sites might have a 
different feed they'd
-                       # like to promote instead of the RC feed (maybe like a 
"Recent New Articles"
-                       # or "Breaking news" one). For this, we see if 
$wgOverrideSiteFeed is defined.
-                       # If so, use it instead.
-                       $sitename = $config->get( 'Sitename' );
-                       if ( $config->get( 'OverrideSiteFeed' ) ) {
-                               foreach ( $config->get( 'OverrideSiteFeed' ) as 
$type => $feedUrl ) {
-                                       // Note, this->feedLink escapes the url.
-                                       $tags[] = $this->feedLink(
-                                               $type,
-                                               $feedUrl,
-                                               $this->msg( 
"site-{$type}-feed", $sitename )->text()
-                                       );
-                               }
-                       } elseif ( !$this->getTitle()->isSpecial( 
'Recentchanges' ) ) {
-                               $rctitle = SpecialPage::getTitleFor( 
'Recentchanges' );
-                               foreach ( $config->get( 'AdvertisedFeedTypes' ) 
as $format ) {
-                                       $tags[] = $this->feedLink(
-                                               $format,
-                                               $rctitle->getLocalURL( array( 
'feed' => $format ) ),
-                                               # For grep: 'site-rss-feed', 
'site-atom-feed'
-                                               $this->msg( 
"site-{$format}-feed", $sitename )->text()
-                                       );
-                               }
+               } elseif ( !$this->getTitle()->isSpecial( 'Recentchanges' ) ) {
+                       $rctitle = SpecialPage::getTitleFor( 'Recentchanges' );
+                       foreach ( $this->getAdvertisedFeedTypes() as $format ) {
+                               $tags[] = $this->feedLink(
+                                       $format,
+                                       $rctitle->getLocalURL( array( 'feed' => 
$format ) ),
+                                       # For grep: 'site-rss-feed', 
'site-atom-feed'
+                                       $this->msg( "site-{$format}-feed", 
$sitename )->text()
+                               );
                        }
                }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/247821
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic64f7f5115a77c42ed2b336f6996fe711b3822ba
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: saper <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to