Merge "Define $wgAlwaysUseTidy to false where needed in unit tests"
[lhc/web/wiklou.git] / includes / Revision.php
index 984da69..3de8303 100644 (file)
@@ -124,7 +124,7 @@ class Revision implements IDBAccessObject {
         * Returns null if no such revision can be found.
         *
         * $flags include:
-        *      Revision::READ_LATEST  : Select the data from the master
+        *      Revision::READ_LATEST  : Select the data from the master (since 1.20)
         *      Revision::READ_LOCKING : Select & lock the data from the master
         *
         * @param $revId Integer
@@ -178,6 +178,13 @@ class Revision implements IDBAccessObject {
                        unset( $attribs['content_format'] );
                }
 
+               if ( !isset( $attribs['title'] )
+                       && isset( $row->ar_namespace )
+                       && isset( $row->ar_title ) ) {
+
+                       $attribs['title'] = Title::makeTitle( $row->ar_namespace, $row->ar_title );
+               }
+
                if ( isset( $row->ar_text ) && !$row->ar_text_id ) {
                        // Pre-1.5 ar_text row
                        $attribs['text'] = self::getRevisionText( $row, 'ar_' );
@@ -600,15 +607,19 @@ class Revision implements IDBAccessObject {
                                $this->mContent = $handler->unserializeContent( $this->mText );
                        }
 
-                       // if we have a Title object, override mPage. Useful for testing and convenience.
-                       if ( isset( $row['title'] ) ) {
-                               $this->mTitle     = $row['title'];
-                               $this->mPage      = $this->mTitle->getArticleID();
-                       } else {
-                               $this->mTitle     = null; // Load on demand if needed
+                       // If we have a Title object, make sure it is consistent with mPage.
+                       if ( $this->mTitle && $this->mTitle->exists() ) {
+                               if ( $this->mPage === null ) {
+                                       // if the page ID wasn't known, set it now
+                                       $this->mPage = $this->mTitle->getArticleID();
+                               } elseif ( $this->mTitle->getArticleID() !== $this->mPage ) {
+                                       // Got different page IDs. This may be legit (e.g. during undeletion),
+                                       // but it seems worth mentioning it in the log.
+                                       wfDebug( "Page ID " . $this->mPage . " mismatches the ID "
+                                                       . $this->mTitle->getArticleID() . " provided by the Title object." );
+                               }
                        }
 
-                       // @todo: XXX: really? we are about to create a revision. it will usually then be the current one.
                        $this->mCurrent   = false;
 
                        // If we still have no length, see it we have the text to figure it out