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
@@ -326,6 +326,13 @@
327327 function rcOutputFeed( $rows, $feedFormat, $limit, $hideminor, $lastmod ) {
328328 global $messageMemc, $wgFeedCacheTimeout;
329329 global $wgFeedClasses, $wgTitle, $wgSitename, $wgContLanguageCode;
 330+ global $wgFeed;
 331+
 332+ if ( !$wgFeed ) {
 333+ global $wgOut;
 334+ $wgOut->addWikiMsg( 'feed-unavailable' );
 335+ return;
 336+ }
330337
331338 if( !isset( $wgFeedClasses[$feedFormat] ) ) {
332339 wfHttpError( 500, "Internal Server Error", "Unsupported feed type." );
Index: trunk/phase3/includes/OutputPage.php
@@ -1337,7 +1337,7 @@
13381338 * @return string HTML tag links to be put in the header.
13391339 */
13401340 public function getHeadLinks() {
1341 - global $wgRequest;
 1341+ global $wgRequest, $wgFeed;
13421342 $ret = '';
13431343 foreach ( $this->mMetatags as $tag ) {
13441344 if ( 0 == strcasecmp( 'http:', substr( $tag[0], 0, 5 ) ) ) {
@@ -1372,33 +1372,35 @@
13731373 $ret .= " />\n";
13741374 }
13751375
1376 - foreach( $this->getSyndicationLinks() as $format => $link ) {
1377 - # Use the page name for the title (accessed through $wgTitle since
1378 - # there's no other way). In principle, this could lead to issues
1379 - # with having the same name for different feeds corresponding to
1380 - # the same page, but we can't avoid that at this low a level.
1381 - global $wgTitle;
1382 -
 1376+ if( $wgFeed ) {
 1377+ foreach( $this->getSyndicationLinks() as $format => $link ) {
 1378+ # Use the page name for the title (accessed through $wgTitle since
 1379+ # there's no other way). In principle, this could lead to issues
 1380+ # with having the same name for different feeds corresponding to
 1381+ # the same page, but we can't avoid that at this low a level.
 1382+ global $wgTitle;
 1383+
 1384+ $ret .= $this->feedLink(
 1385+ $format,
 1386+ $link,
 1387+ wfMsg( "page-{$format}-feed", $wgTitle->getPrefixedText() ) ); # Used messages: 'page-rss-feed' and 'page-atom-feed' (for an easier grep)
 1388+ }
 1389+
 1390+ # Recent changes feed should appear on every page
 1391+ # Put it after the per-page feed to avoid changing existing behavior.
 1392+ # It's still available, probably via a menu in your browser.
 1393+ global $wgSitename;
 1394+ $rctitle = SpecialPage::getTitleFor( 'Recentchanges' );
13831395 $ret .= $this->feedLink(
1384 - $format,
1385 - $link,
1386 - wfMsg( "page-{$format}-feed", $wgTitle->getPrefixedText() ) ); # Used messages: 'page-rss-feed' and 'page-atom-feed' (for an easier grep)
 1396+ 'rss',
 1397+ $rctitle->getFullURL( 'feed=rss' ),
 1398+ wfMsg( 'site-rss-feed', $wgSitename ) );
 1399+ $ret .= $this->feedLink(
 1400+ 'atom',
 1401+ $rctitle->getFullURL( 'feed=atom' ),
 1402+ wfMsg( 'site-atom-feed', $wgSitename ) );
13871403 }
13881404
1389 - # Recent changes feed should appear on every page
1390 - # Put it after the per-page feed to avoid changing existing behavior.
1391 - # It's still available, probably via a menu in your browser.
1392 - global $wgSitename;
1393 - $rctitle = SpecialPage::getTitleFor( 'Recentchanges' );
1394 - $ret .= $this->feedLink(
1395 - 'rss',
1396 - $rctitle->getFullURL( 'feed=rss' ),
1397 - wfMsg( 'site-rss-feed', $wgSitename ) );
1398 - $ret .= $this->feedLink(
1399 - 'atom',
1400 - $rctitle->getFullURL( 'feed=atom' ),
1401 - wfMsg( 'site-atom-feed', $wgSitename ) );
1402 -
14031405 return $ret;
14041406 }
14051407
Index: trunk/phase3/includes/DefaultSettings.php
@@ -2164,6 +2164,9 @@
21652165 /** Use new page patrolling to check new pages on special:Newpages */
21662166 $wgUseNPPatrol = true;
21672167
 2168+/** Provide syndication feeds (RSS, Atom) for eg REcentchanges, Newpages. */
 2169+$wgFeed = true;
 2170+
21682171 /** Set maximum number of results to return in syndication feeds (RSS, Atom) for
21692172 * eg Recentchanges, Newpages. */
21702173 $wgFeedLimit = 50;
Index: trunk/phase3/includes/PageHistory.php
@@ -483,7 +483,14 @@
484484 function feed( $type ) {
485485 require_once 'SpecialRecentchanges.php';
486486
487 - global $wgFeedClasses;
 487+ global $wgFeed, $wgFeedClasses;
 488+
 489+ if ( !$wgFeed ) {
 490+ global $wgOut;
 491+ $wgOut->addWikiMsg( 'feed-unavailable' );
 492+ return;
 493+ }
 494+
488495 if( !isset( $wgFeedClasses[$type] ) ) {
489496 global $wgOut;
490497 $wgOut->addWikiMsg( 'feed-invalid' );
Index: trunk/phase3/includes/QueryPage.php
@@ -448,7 +448,13 @@
449449 * Similar to above, but packaging in a syndicated feed instead of a web page
450450 */
451451 function doFeed( $class = '', $limit = 50 ) {
452 - global $wgFeedClasses;
 452+ global $wgFeed, $wgFeedClasses;
 453+
 454+ if ( !$wgFeed ) {
 455+ global $wgOut;
 456+ $wgOut->addWikiMsg( 'feed-unavailable' );
 457+ return;
 458+ }
453459
454460 if( isset($wgFeedClasses[$class]) ) {
455461 $feed = new $wgFeedClasses[$class](
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -711,6 +711,7 @@
712712 'restorelink' => '{{PLURAL:$1|one deleted edit|$1 deleted edits}}',
713713 'feedlinks' => 'Feed:',
714714 'feed-invalid' => 'Invalid subscription feed type.',
 715+'feed-unavailable' => 'Syndication feeds are not available on {{SITENAME}}',
715716 'site-rss-feed' => '$1 RSS Feed',
716717 'site-atom-feed' => '$1 Atom Feed',
717718 'page-rss-feed' => '"$1" RSS Feed',
Index: trunk/phase3/RELEASE-NOTES
@@ -170,6 +170,7 @@
171171 confused when they are told they are range-blocked.
172172 * Put "not yet written" in the title attribute of red links, so that readers
173173 unfamiliar with the site might guess what the colour means.
 174+* One can turn off syndicatino feeds by setting $wgFeed to false
174175
175176 === Bug fixes in 1.12 ===
176177

Status & tagging log

  • 15:24, 12 September 2011 Meno25 (talk | contribs) changed the status of r31184 [removed: ok added: old]