Followup r78924: keep track of exception/warning comments separately, to prevent...
[lhc/web/wiklou.git] / includes / Article.php
index 8df256a..d3673a3 100644 (file)
@@ -21,7 +21,6 @@ class Article {
        var $mContent;                    // !<
        var $mContentLoaded = false;      // !<
        var $mCounter = -1;               // !< Not loaded
-       var $mCurID = -1;                 // !< Not loaded
        var $mDataLoaded = false;         // !<
        var $mForUpdate = false;          // !<
        var $mGoodAdjustment = 0;         // !<
@@ -119,7 +118,7 @@ class Article {
         */
        public function insertRedirect() {
                // recurse through to only get the final target
-               $retval = Title::newFromRedirectRecurse( $this->getContent() );
+               $retval = Title::newFromRedirectRecurse( $this->getRawText() );
                if ( !$retval ) {
                        return null;
                }
@@ -224,7 +223,7 @@ class Article {
                $this->mDataLoaded    = false;
                $this->mContentLoaded = false;
 
-               $this->mCurID = $this->mUser = $this->mCounter = -1; # Not loaded
+               $this->mUser = $this->mCounter = -1; # Not loaded
                $this->mRedirectedFrom = null; # Title object if set
                $this->mRedirectTarget = null; # Title object if set
                $this->mUserText =
@@ -551,10 +550,9 @@ class Article {
                // We should instead work with the Revision object when we need it...
                $this->mContent   = $revision->getText( Revision::FOR_THIS_USER ); // Loads if user is allowed
 
-               $this->mUser      = $revision->getUser();
-               $this->mUserText  = $revision->getUserText();
-               $this->mComment   = $revision->getComment();
-               $this->mTimestamp = wfTimestamp( TS_MW, $revision->getTimestamp() );
+               if ( $revision->getId() == $this->mLatest ) {
+                       $this->setLastEdit( $revision );
+               }
 
                $this->mRevIdFetched = $revision->getId();
                $this->mContentLoaded = true;
@@ -705,17 +703,25 @@ class Article {
                        return;
                }
 
-               $this->mLastRevision = Revision::loadFromPageId( wfGetDB( DB_MASTER ), $id );
-               if ( !is_null( $this->mLastRevision ) ) {
-                       $this->mUser      = $this->mLastRevision->getUser();
-                       $this->mUserText  = $this->mLastRevision->getUserText();
-                       $this->mTimestamp = $this->mLastRevision->getTimestamp();
-                       $this->mComment   = $this->mLastRevision->getComment();
-                       $this->mMinorEdit = $this->mLastRevision->isMinor();
-                       $this->mRevIdFetched = $this->mLastRevision->getId();
+               $revision = Revision::loadFromPageId( wfGetDB( DB_MASTER ), $id );
+               if ( !is_null( $revision ) ) {
+                       $this->setLastEdit( $revision );
                }
        }
 
+       /**
+        * Set the latest revision
+        */
+       protected function setLastEdit( Revision $revision ) {
+               $this->mLastRevision = $revision;
+               $this->mUser = $revision->getUser();
+               $this->mUserText = $revision->getUserText();
+               $this->mTimestamp = $revision->getTimestamp();
+               $this->mComment = $revision->getComment();
+               $this->mMinorEdit = $revision->isMinor();
+               $this->mRevIdFetched = $revision->getId();
+       }
+
        /**
         * @return string GMT timestamp of last article revision
         **/
@@ -3591,7 +3597,7 @@ class Article {
                $edit->pst = $this->preSaveTransform( $text, $user );
                $edit->popts = $this->getParserOptions( true );
                $edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $edit->popts, true, true, $revid );
-               $edit->oldText = $this->getContent();
+               $edit->oldText = $this->getRawText();
 
                $this->mPreparedEdit = $edit;