*
* MCR migration note: replaced by RevisionStore::newRevisionFromRow(). Note that
* newFromRow() also accepts arrays, while newRevisionFromRow() does not. Instead,
- * a MutableRevisionRecord should be constructed directly. RevisionStore::newRevisionFromArray()
- * can be used as a temporary replacement, but should be avoided.
+ * a MutableRevisionRecord should be constructed directly.
+ * RevisionStore::newMutableRevisionFromArray() can be used as a temporary replacement,
+ * but should be avoided.
*
* @param object|array $row
* @return Revision
* WARNING: Timestamps may in some circumstances not be unique,
* so this isn't the best key to use.
*
- * @deprecated since 1.31, use RevisionStore::loadRevisionFromTimestamp() instead.
+ * @deprecated since 1.31, use RevisionStore::getRevisionByTimestamp()
+ * or RevisionStore::loadRevisionFromTimestamp() instead.
*
* @param IDatabase $db
* @param Title $title
* @return Revision|null
*/
public static function loadFromTimestamp( $db, $title, $timestamp ) {
- // XXX: replace loadRevisionFromTimestamp by getRevisionByTimestamp?
$rec = self::getRevisionStore()->loadRevisionFromTimestamp( $db, $title, $timestamp );
return $rec === null ? null : new Revision( $rec );
}
/**
* Do a batched query to get the parent revision lengths
+ *
+ * @deprecated in 1.31, use RevisionStore::getRevisionSizes instead.
+ *
* @param IDatabase $db
* @param array $revIds
* @return array
if ( $row instanceof RevisionRecord ) {
$this->mRecord = $row;
} elseif ( is_array( $row ) ) {
+ // If no user is specified, fall back to using the global user object, to stay
+ // compatible with pre-1.31 behavior.
if ( !isset( $row['user'] ) && !isset( $row['user_text'] ) ) {
$row['user'] = $wgUser;
}
* @return int Rcid of the unpatrolled row, zero if there isn't one
*/
public function isUnpatrolled() {
- return self::getRevisionStore()->isUnpatrolled( $this->mRecord );
+ return self::getRevisionStore()->getRcIdIfUnpatrolled( $this->mRecord );
}
/**
/**
* MCR migration note: this replaces Revision::isUnpatrolled
*
+ * @todo This is overly specific, so move or kill this method.
+ *
* @param RevisionRecord $rev
+ *
* @return int Rcid of the unpatrolled row, zero if there isn't one
*/
- public function isUnpatrolled( RevisionRecord $rev ) {
+ public function getRcIdIfUnpatrolled( RevisionRecord $rev ) {
$rc = $this->getRecentChange( $rev );
if ( $rc && $rc->getAttribute( 'rc_patrolled' ) == 0 ) {
return $rc->getAttribute( 'rc_id' );
* @param string $timestamp
* @return RevisionRecord|null
*/
- public function getRevisionFromTimestamp( $title, $timestamp ) {
+ public function getRevisionByTimestamp( $title, $timestamp ) {
return $this->newRevisionFromConds(
[
'rev_timestamp' => $timestamp,
*
* MCR migration note: this replaces Revision::getParentLengths
*
+ * @param int[] $revIds
+ * @return int[] associative array mapping revision IDs from $revIds to the nominal size
+ * of the corresponding revision.
+ */
+ public function getRevisionSizes( array $revIds ) {
+ return $this->listRevisionSizes( $this->getDBConnection( DB_REPLICA ), $revIds );
+ }
+
+ /**
+ * Do a batched query for the sizes of a set of revisions.
+ *
+ * MCR migration note: this replaces Revision::getParentLengths
+ *
+ * @deprecated use RevisionStore::getRevisionSizes instead.
+ *
* @param IDatabase $db
* @param int[] $revIds
* @return int[] associative array mapping revision IDs from $revIds to the nominal size
}
/**
- * @covers \MediaWiki\Storage\RevisionStore::isUnpatrolled
+ * @covers \MediaWiki\Storage\RevisionStore::getRcIdIfUnpatrolled
*/
- public function testIsUnpatrolled_returnsRecentChangesId() {
+ public function testGetRcIdIfUnpatrolled_returnsRecentChangesId() {
$page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
$status = $page->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
/** @var Revision $rev */
$store = MediaWikiServices::getInstance()->getRevisionStore();
$revisionRecord = $store->getRevisionById( $rev->getId() );
- $result = $store->isUnpatrolled( $revisionRecord );
+ $result = $store->getRcIdIfUnpatrolled( $revisionRecord );
$this->assertGreaterThan( 0, $result );
$this->assertSame(
}
/**
- * @covers \MediaWiki\Storage\RevisionStore::isUnpatrolled
+ * @covers \MediaWiki\Storage\RevisionStore::getRcIdIfUnpatrolled
*/
- public function testIsUnpatrolled_returnsZeroIfPatrolled() {
+ public function testGetRcIdIfUnpatrolled_returnsZeroIfPatrolled() {
// This assumes that sysops are auto patrolled
$sysop = $this->getTestSysop()->getUser();
$page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
$store = MediaWikiServices::getInstance()->getRevisionStore();
$revisionRecord = $store->getRevisionById( $rev->getId() );
- $result = $store->isUnpatrolled( $revisionRecord );
+ $result = $store->getRcIdIfUnpatrolled( $revisionRecord );
$this->assertSame( 0, $result );
}
}
/**
- * @covers \MediaWiki\Storage\RevisionStore::getRevisionFromTimestamp
+ * @covers \MediaWiki\Storage\RevisionStore::getRevisionByTimestamp
*/
- public function testGetRevisionFromTimestamp() {
+ public function testGetRevisionByTimestamp() {
// Make sure there is 1 second between the last revision and the rev we create...
// Otherwise we might not get the correct revision and the test may fail...
// :(
$rev = $status->value['revision'];
$store = MediaWikiServices::getInstance()->getRevisionStore();
- $revRecord = $store->getRevisionFromTimestamp(
+ $revRecord = $store->getRevisionByTimestamp(
$page->getTitle(),
$rev->getTimestamp()
);
);
}
+ // FIXME: test getRevisionSizes
+
}