r113468 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113467‎ | r113468 | r113469 >
Date:14:50, 9 March 2012
Author:ialex
Status:ok
Tags:
Comment:
Use WikiPage::getRevision() instead of another Revision object if the oldid parameter corresponds to the page's latest revision
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -248,12 +248,16 @@
249249 if ( $oldid !== 0 ) {
250250 # Load the given revision and check whether the page is another one.
251251 # In that case, update this instance to reflect the change.
252 - $this->mRevision = Revision::newFromId( $oldid );
253 - if ( $this->mRevision !== null ) {
254 - // Revision title doesn't match the page title given?
255 - if ( $this->mPage->getID() != $this->mRevision->getPage() ) {
256 - $function = array( get_class( $this->mPage ), 'newFromID' );
257 - $this->mPage = call_user_func( $function, $this->mRevision->getPage() );
 252+ if ( $oldid === $this->mPage->getLatest() ) {
 253+ $this->mRevision = $this->mPage->getRevision();
 254+ } else {
 255+ $this->mRevision = Revision::newFromId( $oldid );
 256+ if ( $this->mRevision !== null ) {
 257+ // Revision title doesn't match the page title given?
 258+ if ( $this->mPage->getID() != $this->mRevision->getPage() ) {
 259+ $function = array( get_class( $this->mPage ), 'newFromID' );
 260+ $this->mPage = call_user_func( $function, $this->mRevision->getPage() );
 261+ }
258262 }
259263 }
260264 }

Status & tagging log