r109542 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109541‎ | r109542 | r109543 >
Date:16:20, 19 January 2012
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Fix object munging to fix (bug 33818) GoogleNewsSitemap failing to return feeds

FeedItem sets ->title to the text, no the object
Modified paths:
  • /trunk/extensions/GoogleNewsSitemap/FeedSMItem.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GoogleNewsSitemap/FeedSMItem.php
@@ -11,6 +11,11 @@
1212 private $keywords = array();
1313
1414 /**
 15+ * @var Title
 16+ */
 17+ private $titleObj;
 18+
 19+ /**
1520 * @param Title $title Title object that this entry is for.
1621 * @param String $pubDate Publish date formattable by wfTimestamp.
1722 * @param Array $keywords list of (String) keywords
@@ -20,7 +25,7 @@
2126 * An integer for the page name of $title in the specific namespace denoted by that integer.
2227 */
2328 public function __construct( $title, $pubDate, $keywords = '', $comment = true ) {
24 - if ( !$title ) {
 29+ if ( !$title || !$title instanceof Title ) {
2530 // Paranoia
2631 throw new MWException( 'Invalid title object passed to FeedSMItem' );
2732 }
@@ -37,8 +42,8 @@
3843 }
3944 }
4045
41 - $this->title = $title;
4246 $this->keywords = $keywords;
 47+ $this->titleObj = $title;
4348
4449 parent::__construct( $title->getText(), '' /* Description */,
4550 $title->getFullURL(), $pubDate, '' /* Author */, $commentsURL );
@@ -62,7 +67,7 @@
6368 }
6469
6570 public function getLastMod() {
66 - return $this->title->getTouched();
 71+ return $this->titleObj->getTouched();
6772 }
6873
6974 public function getKeywords() {
@@ -88,12 +93,9 @@
8994 // but not much worse than the rest of this extension.
9095
9196 $result = '';
92 - if ( !$this->title ) {
93 - return $result;
94 - }
9597 $req = new FauxRequest( array(
9698 'action' => 'parse',
97 - 'page' => $this->title->getPrefixedDBKey(),
 99+ 'page' => $this->titleObj->getPrefixedDBKey(),
98100 'prop' => 'text',
99101 ) );
100102 $main = new ApiMain( $req );

Follow-up revisions

RevisionCommit summaryAuthorDate
r109543MFT r109542reedy16:22, 19 January 2012
r109544MFT r109542reedy16:29, 19 January 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r102851* Renamed member variables to begin with a lower case...ialex09:57, 12 November 2011
r109532* (bug 33818) GoogleNewsSitemap failing to return feeds...reedy14:29, 19 January 2012

Comments

#Comment by Reedy (talk | contribs)   16:25, 19 January 2012

Was caused by r102851 de-capitalising the title object, causing a clash

#Comment by Bsitu (talk | contribs)   19:03, 19 January 2012

"if ( !$title || !$title instanceof Title )"

I think checking if $title is instance of Title is enough

#Comment by Reedy (talk | contribs)   19:27, 19 January 2012

It probably is, yeah. It was somewhat debugging code trying to work out why Title wasn't actually a title object when it came to the time for it to be used

Status & tagging log