SpecialMergeHistory: add redirect=no on target parameter on success message
[lhc/web/wiklou.git] / includes / Revision.php
index 9bb4d16..6584207 100644 (file)
@@ -194,8 +194,8 @@ class Revision implements IDBAccessObject {
 
                if ( !isset( $attribs['title'] )
                        && isset( $row->ar_namespace )
-                       && isset( $row->ar_title ) ) {
-
+                       && isset( $row->ar_title )
+               ) {
                        $attribs['title'] = Title::makeTitle( $row->ar_namespace, $row->ar_title );
                }
 
@@ -773,7 +773,7 @@ class Revision implements IDBAccessObject {
                if ( $this->mTitle !== null ) {
                        return $this->mTitle;
                }
-               //rev_id is defined as NOT NULL, but this revision may not yet have been inserted.
+               // rev_id is defined as NOT NULL, but this revision may not yet have been inserted.
                if ( $this->mId !== null ) {
                        $dbr = wfGetDB( DB_SLAVE );
                        $row = $dbr->selectRow(
@@ -1087,7 +1087,7 @@ class Revision implements IDBAccessObject {
        /**
         * Returns the content model for this revision.
         *
-        * If no content model was stored in the database, $this->getTitle()->getContentModel() is
+        * If no content model was stored in the database, the default content model for the title is
         * used to determine the content model to use. If no title is know, CONTENT_MODEL_WIKITEXT
         * is used as a last resort.
         *
@@ -1097,7 +1097,11 @@ class Revision implements IDBAccessObject {
        public function getContentModel() {
                if ( !$this->mContentModel ) {
                        $title = $this->getTitle();
-                       $this->mContentModel = ( $title ? $title->getContentModel() : CONTENT_MODEL_WIKITEXT );
+                       if ( $title ) {
+                               $this->mContentModel = ContentHandler::getDefaultModelFor( $title );
+                       } else {
+                               $this->mContentModel = CONTENT_MODEL_WIKITEXT;
+                       }
 
                        assert( !empty( $this->mContentModel ) );
                }
@@ -1414,8 +1418,8 @@ class Revision implements IDBAccessObject {
                );
 
                if ( $wgContentHandlerUseDB ) {
-                       //NOTE: Store null for the default model and format, to save space.
-                       //XXX: Makes the DB sensitive to changed defaults.
+                       // NOTE: Store null for the default model and format, to save space.
+                       // XXX: Makes the DB sensitive to changed defaults.
                        // Make this behavior optional? Only in miser mode?
 
                        $model = $this->getContentModel();
@@ -1455,7 +1459,7 @@ class Revision implements IDBAccessObject {
        protected function checkContentModel() {
                global $wgContentHandlerUseDB;
 
-               $title = $this->getTitle(); //note: may return null for revisions that have not yet been inserted.
+               $title = $this->getTitle(); // note: may return null for revisions that have not yet been inserted.
 
                $model = $this->getContentModel();
                $format = $this->getContentFormat();
@@ -1637,8 +1641,9 @@ class Revision implements IDBAccessObject {
                                $row['content_format'] = $current->rev_content_format;
                        }
 
+                       $row['title'] = Title::makeTitle( $current->page_namespace, $current->page_title );
+
                        $revision = new Revision( $row );
-                       $revision->setTitle( Title::makeTitle( $current->page_namespace, $current->page_title ) );
                } else {
                        $revision = null;
                }