Hard deprecate Revision::getContent(Model|Handler|Format)
Bug: T250981 Change-Id: I5b93e65f7a5b12e910c1e36fc39f60f498edf6c4
This commit is contained in:
parent
08dae812d0
commit
b4d8adab32
5 changed files with 42 additions and 2 deletions
|
|
@ -985,6 +985,10 @@ because of Phabricator reports.
|
|||
- ::getUserText - use RevisionRecord::getUser and then User::getName instead
|
||||
- ::isMinor - use RevisionRecord::isMinor instead
|
||||
- ::isCurrent - use RevisionRecord::isCurrent instead
|
||||
- ::getContentModel - use SlotRecord::getModel instead
|
||||
- ::getContentFormat - use SlotRecord::getFormat instead, with a fallback
|
||||
to ContentHandler::getDefaultFormat
|
||||
- ::getContentHandler - use ContentHandlerFactory::getContentHandler instead
|
||||
- ::getParentId - use RevisionRecord::getParentId instead
|
||||
- ::getVisibility - use RevisionRecord::getVisibility instead
|
||||
- ::isDeleted - use RevisionRecord::isDeleted instead
|
||||
|
|
|
|||
|
|
@ -799,12 +799,14 @@ class Revision implements IDBAccessObject {
|
|||
* used to determine the content model to use. If no title is know, CONTENT_MODEL_WIKITEXT
|
||||
* is used as a last resort.
|
||||
*
|
||||
* @todo drop this, with MCR, there no longer is a single model associated with a revision.
|
||||
* @deprecated since 1.31 (soft), 1.35 (hard)
|
||||
*
|
||||
* @return string The content model id associated with this revision,
|
||||
* see the CONTENT_MODEL_XXX constants.
|
||||
*/
|
||||
public function getContentModel() {
|
||||
wfDeprecated( __METHOD__, '1.31' );
|
||||
|
||||
$slot = $this->getMainSlotRaw();
|
||||
|
||||
if ( $slot ) {
|
||||
|
|
@ -822,12 +824,14 @@ class Revision implements IDBAccessObject {
|
|||
* If no content format was stored in the database, the default format for this
|
||||
* revision's content model is returned.
|
||||
*
|
||||
* @todo drop this, the format is irrelevant to the revision!
|
||||
* @deprecated since 1.31 (soft), 1.35 (hard)
|
||||
*
|
||||
* @return string The content format id associated with this revision,
|
||||
* see the CONTENT_FORMAT_XXX constants.
|
||||
*/
|
||||
public function getContentFormat() {
|
||||
wfDeprecated( __METHOD__, '1.31' );
|
||||
|
||||
$slot = $this->getMainSlotRaw();
|
||||
$format = $slot ? $this->getMainSlotRaw()->getFormat() : null;
|
||||
|
||||
|
|
@ -842,10 +846,14 @@ class Revision implements IDBAccessObject {
|
|||
/**
|
||||
* Returns the content handler appropriate for this revision's content model.
|
||||
*
|
||||
* @deprecated since 1.31 (soft), 1.35 (hard)
|
||||
*
|
||||
* @throws MWException
|
||||
* @return ContentHandler
|
||||
*/
|
||||
public function getContentHandler() {
|
||||
wfDeprecated( __METHOD__, '1.31' );
|
||||
|
||||
return MediaWikiServices::getInstance()
|
||||
->getContentHandlerFactory()
|
||||
->getContentHandler( $this->getContentModel() );
|
||||
|
|
|
|||
|
|
@ -928,6 +928,9 @@ abstract class RevisionStoreDbTestBase extends MediaWikiTestCase {
|
|||
$this->hideDeprecated( 'Revision::isMinor' );
|
||||
$this->hideDeprecated( 'Revision::getParentId' );
|
||||
$this->hideDeprecated( 'Revision::getVisibility' );
|
||||
$this->hideDeprecated( 'Revision::getContentFormat' );
|
||||
$this->hideDeprecated( 'Revision::getContentHandler' );
|
||||
$this->hideDeprecated( 'Revision::getContentModel' );
|
||||
|
||||
$this->assertSame( $rev->getId(), $record->getId() );
|
||||
$this->assertSame( $rev->getPage(), $record->getPageId() );
|
||||
|
|
@ -2140,6 +2143,8 @@ abstract class RevisionStoreDbTestBase extends MediaWikiTestCase {
|
|||
* @throws \MWException
|
||||
*/
|
||||
public function testGetContentBlobsForBatch( $slots ) {
|
||||
$this->hideDeprecated( 'Revision::getContentModel' );
|
||||
|
||||
$page1 = $this->getTestPage();
|
||||
$text = __METHOD__ . 'b-ä';
|
||||
$editStatus = $this->editPage( $page1->getTitle()->getPrefixedDBkey(), $text . '1' );
|
||||
|
|
|
|||
|
|
@ -188,6 +188,9 @@ class RevisionDbTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
private function assertRevEquals( Revision $orig, Revision $rev = null ) {
|
||||
$this->hideDeprecated( 'Revision::getSha1' );
|
||||
$this->hideDeprecated( 'Revision::getContentFormat' );
|
||||
$this->hideDeprecated( 'Revision::getContentHandler' );
|
||||
$this->hideDeprecated( 'Revision::getContentModel' );
|
||||
|
||||
$this->assertNotNull( $rev, 'missing revision' );
|
||||
|
||||
|
|
@ -968,6 +971,8 @@ class RevisionDbTest extends MediaWikiIntegrationTestCase {
|
|||
* @covers Revision::getContentModel
|
||||
*/
|
||||
public function testGetContentModel( $text, $title, $model, $format, $expectedModel ) {
|
||||
$this->hideDeprecated( 'Revision::getContentModel' );
|
||||
|
||||
$rev = $this->newTestRevision( $text, $title, $model, $format );
|
||||
|
||||
$this->assertEquals( $expectedModel, $rev->getContentModel() );
|
||||
|
|
@ -977,6 +982,8 @@ class RevisionDbTest extends MediaWikiIntegrationTestCase {
|
|||
* @covers Revision::getContentModel
|
||||
*/
|
||||
public function testGetContentModelForEmptyRevision() {
|
||||
$this->hideDeprecated( 'Revision::getContentModel' );
|
||||
|
||||
$rev = new Revision( [], 0, $this->testPage->getTitle() );
|
||||
|
||||
$slotRoleHandler = MediaWikiServices::getInstance()->getSlotRoleRegistry()
|
||||
|
|
@ -1001,6 +1008,10 @@ class RevisionDbTest extends MediaWikiIntegrationTestCase {
|
|||
* @covers Revision::getContentFormat
|
||||
*/
|
||||
public function testGetContentFormat( $text, $title, $model, $format, $expectedFormat ) {
|
||||
$this->hideDeprecated( 'Revision::getContentFormat' );
|
||||
$this->hideDeprecated( 'Revision::getContentHandler' );
|
||||
$this->hideDeprecated( 'Revision::getContentModel' );
|
||||
|
||||
$rev = $this->newTestRevision( $text, $title, $model, $format );
|
||||
|
||||
$this->assertEquals( $expectedFormat, $rev->getContentFormat() );
|
||||
|
|
@ -1010,6 +1021,10 @@ class RevisionDbTest extends MediaWikiIntegrationTestCase {
|
|||
* @covers Revision::getContentFormat
|
||||
*/
|
||||
public function testGetContentFormatForEmptyRevision() {
|
||||
$this->hideDeprecated( 'Revision::getContentFormat' );
|
||||
$this->hideDeprecated( 'Revision::getContentHandler' );
|
||||
$this->hideDeprecated( 'Revision::getContentModel' );
|
||||
|
||||
$rev = new Revision( [], 0, $this->testPage->getTitle() );
|
||||
|
||||
$slotRoleHandler = MediaWikiServices::getInstance()->getSlotRoleRegistry()
|
||||
|
|
@ -1035,6 +1050,9 @@ class RevisionDbTest extends MediaWikiIntegrationTestCase {
|
|||
* @covers Revision::getContentHandler
|
||||
*/
|
||||
public function testGetContentHandler( $text, $title, $model, $format, $expectedClass ) {
|
||||
$this->hideDeprecated( 'Revision::getContentHandler' );
|
||||
$this->hideDeprecated( 'Revision::getContentModel' );
|
||||
|
||||
$rev = $this->newTestRevision( $text, $title, $model, $format );
|
||||
|
||||
$this->assertEquals( $expectedClass, get_class( $rev->getContentHandler() ) );
|
||||
|
|
@ -1556,6 +1574,9 @@ class RevisionDbTest extends MediaWikiIntegrationTestCase {
|
|||
public function testSimpleContentGetters() {
|
||||
$this->hideDeprecated( 'Revision::getSerializedData' );
|
||||
$this->hideDeprecated( 'WikiPage::getRevision' );
|
||||
$this->hideDeprecated( 'Revision::getContentFormat' );
|
||||
$this->hideDeprecated( 'Revision::getContentHandler' );
|
||||
$this->hideDeprecated( 'Revision::getContentModel' );
|
||||
|
||||
$expectedText = 'testSimpleContentGetters in Revision. Goats love MCR...';
|
||||
$expectedSummary = 'goatlicious testSimpleContentGetters summary';
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ class RevisionTest extends MediaWikiTestCase {
|
|||
* @covers \MediaWiki\Revision\RevisionStore::newMutableRevisionFromArray
|
||||
*/
|
||||
public function testConstructFromArray( $rowArray ) {
|
||||
$this->hideDeprecated( 'Revision::getContentModel' );
|
||||
|
||||
$rev = new Revision( $rowArray, 0, $this->getMockTitle() );
|
||||
$this->assertNotNull( $rev->getContent(), 'no content object available' );
|
||||
$this->assertEquals( CONTENT_MODEL_JAVASCRIPT, $rev->getContent()->getModel() );
|
||||
|
|
|
|||
Loading…
Reference in a new issue