r78114 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78113‎ | r78114 | r78115 >
Date:02:51, 9 December 2010
Author:reedy
Status:deferred
Tags:
Comment:
Add a bit of sanity back
Modified paths:
  • /trunk/extensions/GoogleNewsSitemap/FeedSMItem.php (modified) (history)
  • /trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php (modified) (history)
  • /trunk/extensions/GoogleNewsSitemap/SitemapFeed.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php
@@ -51,7 +51,6 @@
5252 var $wgDPLallowUnlimitedResults = true; // Allow unlimited results
5353 var $wgDPLallowUnlimitedCategories = false; // Allow unlimited categories
5454
55 -
5655 /**
5756 * @var array Parameters array
5857 **/
@@ -70,25 +69,20 @@
7170 * main()
7271 **/
7372 public function execute( $par ) {
74 - global $wgUser;
75 - global $wgLang;
76 - global $wgContLang;
77 - global $wgRequest, $wgOut;
78 - global $wgSitename, $wgServer, $wgScriptPath;
79 - // global $wfTimeStamp;
80 - wfLoadExtensionMessages( 'GoogleNewsSitemap' );
81 - global $wgFeedClasses, $wgLocaltimezone;
 73+ global $wgUser, $wgLang, $wgContLang, $wgRequest, $wgOut,
 74+ $wgSitename, $wgServer, $wgScriptPath, $wgFeedClasses,
 75+ $wgLocaltimezone;
8276
8377 // Not sure how clean $wgLocaltimezone is
8478 // In fact, it's default setting is null...
85 - if ( null == $wgLocaltimezone )
 79+ if ( null == $wgLocaltimezone ) {
8680 $wgLocaltimezone = date_default_timezone_get();
 81+ }
8782 date_default_timezone_set( $wgLocaltimezone );
8883 // $url = __FILE__;
8984
9085 $this->unload_params(); // populates this->params as a side effect
9186
92 -
9387 $wgFeedClasses[] = array( 'sitemap' => 'SitemapFeed' );
9488
9589 if ( 'sitemap' == $this->params['feed'] ) {
@@ -117,7 +111,7 @@
118112 return;
119113 }
120114
121 - $dbr =& wfGetDB( DB_SLAVE );
 115+ $dbr = wfGetDB( DB_SLAVE );
122116 $sql = $this->dpl_buildSQL();
123117 // Debug line
124118 // echo "\n<p>$sql</p>\n";
@@ -126,16 +120,17 @@
127121 // FIXME: figure out how to fail with no results gracefully
128122 if ( $dbr->numRows( $res ) == 0 ) {
129123 $feed->outFooter();
130 - if ( false == $this->params['suppressErrors'] )
 124+ if ( false == $this->params['suppressErrors'] ) {
131125 return htmlspecialchars( wfMsg( 'gnsm_noresults' ) );
132 - else
 126+ } else {
133127 return '';
 128+ }
134129 }
135130
136131 while ( $row = $dbr->fetchObject( $res ) ) {
137132 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
138133
139 - if ( ! $title ) {
 134+ if ( !$title ) {
140135 $feed->outFooter();
141136 return;
142137 }
@@ -298,8 +293,10 @@
299294 // $this->notCategories[] = $wgRequest->getArray('notcategory');
300295 $this->params['nameSpace'] = $wgContLang->getNsIndex( $wgRequest->getVal( 'namespace', 0 ) );
301296 $this->params['count'] = $wgRequest->getInt( 'count', $this->wgDPLmaxResultCount );
302 - if ( ( $this->params['count'] > $this->wgDPLmaxResultCount ) || ( $this->params['count'] < $this->wgDPLminResultCount ) )
 297+ if ( ( $this->params['count'] > $this->wgDPLmaxResultCount )
 298+ || ( $this->params['count'] < $this->wgDPLminResultCount ) ) {
303299 $this->params['count'] = $this->wgDPLmaxResultCount;
 300+ }
304301
305302 $this->params['order'] = $wgRequest->getVal( 'order', 'descending' );
306303 $this->params['orderMethod'] = $wgRequest->getVal( 'ordermethod', 'categoryadd' );
@@ -311,7 +308,6 @@
312309 $this->params['useCurId'] = $wgRequest->getBool( 'usecurid', false );
313310 $this->params['feed'] = $wgRequest->getVal( 'feed', 'sitemap' );
314311
315 -
316312 $this->params['catCount'] = count( $this->categories );
317313 $this->params['notCatCount'] = count( $this->notCategories );
318314 $totalCatCount = $this->params['catCount'] + $this->params['notCatCount'];
@@ -334,13 +330,13 @@
335331 }
336332
337333 // disallow showing date if the query doesn't have an inclusion category parameter
338 - if ( $this->params['count'] < 1 )
 334+ if ( $this->params['count'] < 1 ) {
339335 $this->params['addFirstCategoryDate'] = false;
 336+ }
340337
341338 $this->params['dbr'] =& wfGetDB( DB_SLAVE );
342339 // print_r($this->notCategories);
343340 // print_r($this->categories);
344 - return;
345341 }
346342
347343 function feedItemAuthor( $row ) {
Index: trunk/extensions/GoogleNewsSitemap/FeedSMItem.php
@@ -10,11 +10,7 @@
1111 /**
1212 * Var string
1313 **/
14 - var $url = '';
15 - var $pubDate = '';
16 - var $keywords = '';
17 - var $lastMod = '';
18 - var $priority = '';
 14+ var $url = '', $pubDate = '', $keywords = '', $lastMod = '', $priority = '';
1915
2016 function __construct( $url, $pubDate, $keywords = '', $lastMod = '', $priority = '' ) {
2117 $this->url = $url;
Index: trunk/extensions/GoogleNewsSitemap/SitemapFeed.php
@@ -13,8 +13,7 @@
1414 * Output feed headers
1515 **/
1616 function outHeader() {
17 - global $wgOut;
18 - global $wgRequest;
 17+ global $wgOut, $wgRequest;
1918
2019 // FIXME: Why can't we just pick one mime type and always send that?
2120 $ctype = $wgRequest->getVal( 'ctype', 'application/xml' );
@@ -36,7 +35,6 @@
3736 * @param FeedSMItem item to be output
3837 **/
3938 function outItem( $item ) {
40 -
4139 $this->writer->startElement( "url" );
4240 $this->writer->startElement( "loc" );
4341 $this->writer->text( $item->getUrl() );

Status & tagging log