r45635 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45634‎ | r45635 | r45636 >
Date:13:41, 10 January 2009
Author:aaron
Status:ok
Tags:
Comment:
* Added getRawText() convenience function to always get the current revision
* Fix incorrect usage of getContent() which broke if ?oldid was set
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -228,6 +228,21 @@
229229 return $this->mContent;
230230 }
231231 }
 232+
 233+ /**
 234+ * Get the text of the current revision. No side-effects...
 235+ *
 236+ * @return Return the text of the current revision
 237+ */
 238+ public function getRawText() {
 239+ // Check process cache for current revision
 240+ if( $this->mContentLoaded && $this->mOldId == 0 ) {
 241+ return $this->mContent;
 242+ }
 243+ $rev = Revision::newFromTitle( $this->mTitle );
 244+ $text = $rev ? $rev->getRawText() : false;
 245+ return $text;
 246+ }
232247
233248 /**
234249 * This function returns the text of a section, specified by a number ($section).
@@ -1128,7 +1143,7 @@
11291144 if( $this->getID() == 0 ) {
11301145 $text = false;
11311146 } else {
1132 - $text = $this->getContent();
 1147+ $text = $this->getRawText();
11331148 }
11341149 $wgMessageCache->replace( $this->mTitle->getDBkey(), $text );
11351150 }
@@ -1490,7 +1505,7 @@
14911506 $isminor = ( $flags & EDIT_MINOR ) && $user->isAllowed('minoredit');
14921507 $bot = $flags & EDIT_FORCE_BOT;
14931508
1494 - $oldtext = $this->getContent();
 1509+ $oldtext = $this->getRawText(); // current revision
14951510 $oldsize = strlen( $oldtext );
14961511
14971512 # Provide autosummaries if one is not provided and autosummaries are enabled.
@@ -2398,7 +2413,7 @@
23992414 return false;
24002415 }
24012416
2402 - $u = new SiteStatsUpdate( 0, 1, -(int)$this->isCountable( $this->getContent() ), -1 );
 2417+ $u = new SiteStatsUpdate( 0, 1, -(int)$this->isCountable( $this->getRawText() ), -1 );
24032418 array_push( $wgDeferredUpdateList, $u );
24042419
24052420 // Bitfields to further suppress the content

Status & tagging log