From: Legoktm Date: Sun, 10 Jul 2016 22:58:36 +0000 (+0000) Subject: Revert "If rev_content_model is null, use page_content_model." X-Git-Tag: 1.31.0-rc.0~6414^2 X-Git-Url: http://git.cyclocoop.org/data/%24oldEdit?a=commitdiff_plain;h=c9021e17639ad091e282dc939a64e6602d8ddb60;p=lhc%2Fweb%2Fwiklou.git Revert "If rev_content_model is null, use page_content_model." This patch effectively reverted a5bc9f49cd01e49c, which was the correct behavior. If a page were to have its content model changed, the NULL revision rows would now be interpreted as the page's new content model instead of the default content model (which they should be). This reverts commit 9a6ff0bd82faafbf9746a6fa3ed33f42092587c3. Change-Id: I6801d09bd847f477222e503b912005b02a9df045 --- diff --git a/includes/Revision.php b/includes/Revision.php index 5c4302e9bb..eda898916c 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -1110,7 +1110,7 @@ class Revision implements IDBAccessObject { if ( !$this->mContentModel ) { $title = $this->getTitle(); if ( $title ) { - $this->mContentModel = $title->getContentModel(); + $this->mContentModel = ContentHandler::getDefaultModelFor( $title ); } else { $this->mContentModel = CONTENT_MODEL_WIKITEXT; } @@ -1455,7 +1455,7 @@ class Revision implements IDBAccessObject { . "revision's page!" ); } - $defaultModel = $title->getContentModel(); + $defaultModel = ContentHandler::getDefaultModelFor( $title ); $defaultFormat = ContentHandler::getForModelID( $defaultModel )->getDefaultFormat(); $row['rev_content_model'] = ( $model === $defaultModel ) ? null : $model; diff --git a/tests/phpunit/includes/RevisionStorageTest.php b/tests/phpunit/includes/RevisionStorageTest.php index 38661907a5..7d3007bf40 100644 --- a/tests/phpunit/includes/RevisionStorageTest.php +++ b/tests/phpunit/includes/RevisionStorageTest.php @@ -317,42 +317,7 @@ class RevisionStorageTest extends MediaWikiTestCase { /** * @covers Revision::getContentModel */ - public function testGetContentModel_default_model() { - global $wgContentHandlerUseDB; - - if ( !$wgContentHandlerUseDB ) { - $this->markTestSkipped( '$wgContentHandlerUseDB is disabled' ); - } - - $orig = $this->makeRevision( [ 'text' => 'hello hello.', ] ); - - // Change namespace default content model, to make sure getContentModel() uses the - // page content model, not the namespace default. - $ns = $this->getDefaultWikitextNS(); - $this->mergeMwGlobalArrayValue( 'wgNamespaceContentModels', [ $ns => CONTENT_MODEL_JSON ] ); - - $rev = Revision::newFromId( $orig->getId() ); - - // we should still get the correct content model from the page table - $this->assertEquals( CONTENT_MODEL_WIKITEXT, $rev->getContentModel() ); - - // check that we don't null the revision model if it's equal to the default, but not to - // the current page model. - $second = $this->makeRevision( [ - 'text' => '{ "say":"hello" }', - 'content_model' => CONTENT_MODEL_JAVASCRIPT - ] ); - - $rev = Revision::newFromId( $second->getId() ); - - // we should now get the content model from the revision table - $this->assertEquals( CONTENT_MODEL_JAVASCRIPT, $rev->getContentModel() ); - } - - /** - * @covers Revision::getContentModel - */ - public function testGetContentModel_other_model() { + public function testGetContentModel() { global $wgContentHandlerUseDB; if ( !$wgContentHandlerUseDB ) { @@ -360,7 +325,7 @@ class RevisionStorageTest extends MediaWikiTestCase { } $orig = $this->makeRevision( [ 'text' => 'hello hello.', - 'content_model' => CONTENT_MODEL_JAVASCRIPT ] ); + 'content_model' => CONTENT_MODEL_JAVASCRIPT ] ); $rev = Revision::newFromId( $orig->getId() ); $this->assertEquals( CONTENT_MODEL_JAVASCRIPT, $rev->getContentModel() );