Define RevisionRecord::isCurrent
Currently only RevisionStoreRecord::isCurrent exists, and it is the only implementation where the method makes sence. However, checking with instanceof prior to calling it for every RevisionRecord is inconvenient. This patch pulls the method up into RevisionRecord with default implementation returning false. Change-Id: I89852ca210b29825ce8fc9e13610e892c650ba14
This commit is contained in:
parent
ccf5b970f4
commit
7566934239
4 changed files with 27 additions and 3 deletions
|
|
@ -574,6 +574,15 @@ abstract class RevisionRecord {
|
||||||
&& $this->mSlots->getSlotRoles() !== [];
|
&& $this->mSlots->getSlotRoles() !== [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the revision record is a stored current revision.
|
||||||
|
* @since 1.35
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isCurrent() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -105,9 +105,7 @@ class RevisionStoreRecord extends RevisionRecord {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MCR migration note: this replaces Revision::isCurrent
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public function isCurrent() {
|
public function isCurrent() {
|
||||||
return $this->mCurrent;
|
return $this->mCurrent;
|
||||||
|
|
|
||||||
|
|
@ -349,4 +349,13 @@ class MutableRevisionRecordTest extends MediaWikiTestCase {
|
||||||
public function testNotReadyForInsertion( $rev ) {
|
public function testNotReadyForInsertion( $rev ) {
|
||||||
$this->assertFalse( $rev->isReadyForInsertion() );
|
$this->assertFalse( $rev->isReadyForInsertion() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \MediaWiki\Revision\RevisionRecord::isCurrent
|
||||||
|
*/
|
||||||
|
public function testIsCurrent() {
|
||||||
|
$rev = new MutableRevisionRecord( Title::newFromText( 'Foo' ) );
|
||||||
|
$this->assertFalse( $rev->isCurrent(),
|
||||||
|
MutableRevisionRecord::class . ' cannot be stored current revision' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -269,4 +269,12 @@ class RevisionArchiveRecordTest extends MediaWikiTestCase {
|
||||||
new RevisionArchiveRecord( $title, $user, $comment, $row, $slots, $wikiId );
|
new RevisionArchiveRecord( $title, $user, $comment, $row, $slots, $wikiId );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \MediaWiki\Revision\RevisionRecord::isCurrent
|
||||||
|
*/
|
||||||
|
public function testIsCurrent() {
|
||||||
|
$rev = $this->newRevision();
|
||||||
|
$this->assertFalse( $rev->isCurrent(),
|
||||||
|
RevisionArchiveRecord::class . ' cannot be stored current revision' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue