From: Alexandre Emsenhuber Date: Fri, 9 Mar 2012 14:50:39 +0000 (+0000) Subject: Use WikiPage::getRevision() instead of another Revision object if the oldid parameter... X-Git-Tag: 1.31.0-rc.0~24323 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=08efa9be8877ba4181bdcb1cbee876b2944c0891;p=lhc%2Fweb%2Fwiklou.git Use WikiPage::getRevision() instead of another Revision object if the oldid parameter corresponds to the page's latest revision --- diff --git a/includes/Article.php b/includes/Article.php index 6356f1a654..cdf2c1f4a6 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -248,12 +248,16 @@ class Article extends Page { if ( $oldid !== 0 ) { # Load the given revision and check whether the page is another one. # In that case, update this instance to reflect the change. - $this->mRevision = Revision::newFromId( $oldid ); - if ( $this->mRevision !== null ) { - // Revision title doesn't match the page title given? - if ( $this->mPage->getID() != $this->mRevision->getPage() ) { - $function = array( get_class( $this->mPage ), 'newFromID' ); - $this->mPage = call_user_func( $function, $this->mRevision->getPage() ); + if ( $oldid === $this->mPage->getLatest() ) { + $this->mRevision = $this->mPage->getRevision(); + } else { + $this->mRevision = Revision::newFromId( $oldid ); + if ( $this->mRevision !== null ) { + // Revision title doesn't match the page title given? + if ( $this->mPage->getID() != $this->mRevision->getPage() ) { + $function = array( get_class( $this->mPage ), 'newFromID' ); + $this->mPage = call_user_func( $function, $this->mRevision->getPage() ); + } } } }