MediaWiki r31184 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r31183‎ | r31184 (on ViewVC)‎ | r31185 >
Date:12:33, 22 February 2008
Author:huji
Status:old
Tags:
Comment:
Introducing $wgFeed variable. Allows tuning sydication feeds off, when desired.
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/SpecialRecentchanges.php
===================================================================
--- trunk/phase3/includes/SpecialRecentchanges.php	(revision 31183)
+++ trunk/phase3/includes/SpecialRecentchanges.php	(revision 31184)
@@ -326,6 +326,13 @@
 function rcOutputFeed( $rows, $feedFormat, $limit, $hideminor, $lastmod ) {
 	global $messageMemc, $wgFeedCacheTimeout;
 	global $wgFeedClasses, $wgTitle, $wgSitename, $wgContLanguageCode;
+	global $wgFeed;
+	
+	if ( !$wgFeed ) {
+		global $wgOut;
+		$wgOut->addWikiMsg( 'feed-unavailable' );
+		return;
+	}
 
 	if( !isset( $wgFeedClasses[$feedFormat] ) ) {
 		wfHttpError( 500, "Internal Server Error", "Unsupported feed type." );
Index: trunk/phase3/includes/OutputPage.php
===================================================================
--- trunk/phase3/includes/OutputPage.php	(revision 31183)
+++ trunk/phase3/includes/OutputPage.php	(revision 31184)
@@ -1337,7 +1337,7 @@
 	 * @return string HTML tag links to be put in the header.
 	 */
 	public function getHeadLinks() {
-		global $wgRequest;
+		global $wgRequest, $wgFeed;
 		$ret = '';
 		foreach ( $this->mMetatags as $tag ) {
 			if ( 0 == strcasecmp( 'http:', substr( $tag[0], 0, 5 ) ) ) {
@@ -1372,33 +1372,35 @@
 			$ret .= " />\n";
 		}
 		
-		foreach( $this->getSyndicationLinks() as $format => $link ) {
-			# Use the page name for the title (accessed through $wgTitle since
-			# there's no other way).  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.
-			global $wgTitle;
-
+		if( $wgFeed ) {
+			foreach( $this->getSyndicationLinks() as $format => $link ) {
+				# Use the page name for the title (accessed through $wgTitle since
+				# there's no other way).  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.
+				global $wgTitle;
+	
+				$ret .= $this->feedLink(
+					$format,
+					$link,
+					wfMsg( "page-{$format}-feed", $wgTitle->getPrefixedText() ) ); # Used messages: 'page-rss-feed' and 'page-atom-feed' (for an easier grep)
+			}
+	
+			# Recent changes feed should appear on every page
+			# Put it after the per-page feed to avoid changing existing behavior.
+			# It's still available, probably via a menu in your browser.
+			global $wgSitename;
+			$rctitle = SpecialPage::getTitleFor( 'Recentchanges' );
 			$ret .= $this->feedLink(
-				$format,
-				$link,
-				wfMsg( "page-{$format}-feed", $wgTitle->getPrefixedText() ) ); # Used messages: 'page-rss-feed' and 'page-atom-feed' (for an easier grep)
+				'rss',
+				$rctitle->getFullURL( 'feed=rss' ),
+				wfMsg( 'site-rss-feed', $wgSitename ) );
+			$ret .= $this->feedLink(
+				'atom',
+				$rctitle->getFullURL( 'feed=atom' ),
+				wfMsg( 'site-atom-feed', $wgSitename ) );
 		}
 
-		# Recent changes feed should appear on every page
-		# Put it after the per-page feed to avoid changing existing behavior.
-		# It's still available, probably via a menu in your browser.
-		global $wgSitename;
-		$rctitle = SpecialPage::getTitleFor( 'Recentchanges' );
-		$ret .= $this->feedLink(
-			'rss',
-			$rctitle->getFullURL( 'feed=rss' ),
-			wfMsg( 'site-rss-feed', $wgSitename ) );
-		$ret .= $this->feedLink(
-			'atom',
-			$rctitle->getFullURL( 'feed=atom' ),
-			wfMsg( 'site-atom-feed', $wgSitename ) );
-
 		return $ret;
 	}
 	
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 31183)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 31184)
@@ -2164,6 +2164,9 @@
 /** Use new page patrolling to check new pages on special:Newpages */
 $wgUseNPPatrol = true;
 
+/** Provide syndication feeds (RSS, Atom) for eg REcentchanges, Newpages. */
+$wgFeed = true;
+
 /** Set maximum number of results to return in syndication feeds (RSS, Atom) for
  * eg Recentchanges, Newpages. */
 $wgFeedLimit = 50;
Index: trunk/phase3/includes/PageHistory.php
===================================================================
--- trunk/phase3/includes/PageHistory.php	(revision 31183)
+++ trunk/phase3/includes/PageHistory.php	(revision 31184)
@@ -483,7 +483,14 @@
 	function feed( $type ) {
 		require_once 'SpecialRecentchanges.php';
 		
-		global $wgFeedClasses;
+		global $wgFeed, $wgFeedClasses;
+		
+		if ( !$wgFeed ) {
+			global $wgOut;
+			$wgOut->addWikiMsg( 'feed-unavailable' );
+			return;
+		}
+		
 		if( !isset( $wgFeedClasses[$type] ) ) {
 			global $wgOut;
 			$wgOut->addWikiMsg( 'feed-invalid' );
Index: trunk/phase3/includes/QueryPage.php
===================================================================
--- trunk/phase3/includes/QueryPage.php	(revision 31183)
+++ trunk/phase3/includes/QueryPage.php	(revision 31184)
@@ -448,7 +448,13 @@
 	 * Similar to above, but packaging in a syndicated feed instead of a web page
 	 */
 	function doFeed( $class = '', $limit = 50 ) {
-		global $wgFeedClasses;
+		global $wgFeed, $wgFeedClasses;
+		
+		if ( !$wgFeed ) {
+			global $wgOut;
+			$wgOut->addWikiMsg( 'feed-unavailable' );
+			return;
+		}
 
 		if( isset($wgFeedClasses[$class]) ) {
 			$feed = new $wgFeedClasses[$class](
Index: trunk/phase3/languages/messages/MessagesEn.php
===================================================================
--- trunk/phase3/languages/messages/MessagesEn.php	(revision 31183)
+++ trunk/phase3/languages/messages/MessagesEn.php	(revision 31184)
@@ -711,6 +711,7 @@
 'restorelink'                  => '{{PLURAL:$1|one deleted edit|$1 deleted edits}}',
 'feedlinks'                    => 'Feed:',
 'feed-invalid'                 => 'Invalid subscription feed type.',
+'feed-unavailable'             => 'Syndication feeds are not available on {{SITENAME}}',
 'site-rss-feed'                => '$1 RSS Feed',
 'site-atom-feed'               => '$1 Atom Feed',
 'page-rss-feed'                => '"$1" RSS Feed',
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 31183)
+++ trunk/phase3/RELEASE-NOTES	(revision 31184)
@@ -170,6 +170,7 @@
   confused when they are told they are range-blocked.
 * Put "not yet written" in the title attribute of red links, so that readers
   unfamiliar with the site might guess what the colour means.
+* One can turn off syndicatino feeds by setting $wgFeed to false
 
 === Bug fixes in 1.12 ===
 

Status & tagging log

  • 15:24, 12 September 2011 Meno25 (Talk | contribs) changed the status of r31184 [removed: ok added: old]
Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox