}
/**
+ * @param bool|string $wikiId The ID of the target wiki database. Use false for the local wiki.
+ *
* @return SqlBlobStore
*/
- protected static function getBlobStore() {
- $store = MediaWikiServices::getInstance()->getBlobStore();
+ protected static function getBlobStore( $wiki = false ) {
+ $store = MediaWikiServices::getInstance()
+ ->getBlobStoreFactory()
+ ->newSqlBlobStore( $wiki );
if ( !$store instanceof SqlBlobStore ) {
throw new RuntimeException(
*
* @param int $id
* @param int $flags (optional)
- * @param Title $title (optional)
* @return Revision|null
*/
- public static function newFromId( $id, $flags = 0, Title $title = null ) {
- $rec = self::getRevisionStore()->getRevisionById( $id, $flags, $title );
- return $rec === null ? null : new Revision( $rec, $flags, $title );
+ public static function newFromId( $id, $flags = 0 ) {
+ $rec = self::getRevisionStore()->getRevisionById( $id, $flags );
+ return $rec === null ? null : new Revision( $rec, $flags );
}
/**
*
* @param object $row
* @param array $overrides
- * @param Title $title (optional)
*
* @throws MWException
* @return Revision
*/
- public static function newFromArchiveRow( $row, $overrides = [], Title $title = null ) {
+ public static function newFromArchiveRow( $row, $overrides = [] ) {
/**
* MCR Migration: https://phabricator.wikimedia.org/T183564
* This method used to overwrite attributes, then passed to Revision::__construct
unset( $overrides['page'] );
}
+ /**
+ * We require a Title for both the Revision object and the RevisionRecord.
+ * Below is duplicated logic from RevisionStore::newRevisionFromArchiveRow
+ * to fetch a title in order pass it into the Revision object.
+ */
+ $title = null;
+ if ( isset( $overrides['title'] ) ) {
+ if ( !( $overrides['title'] instanceof Title ) ) {
+ throw new MWException( 'title field override must contain a Title object.' );
+ }
+
+ $title = $overrides['title'];
+ }
+ if ( $title !== null ) {
+ if ( isset( $row->ar_namespace ) && isset( $row->ar_title ) ) {
+ $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
+ } else {
+ throw new InvalidArgumentException(
+ 'A Title or ar_namespace and ar_title must be given'
+ );
+ }
+ }
+
$rec = self::getRevisionStore()->newRevisionFromArchiveRow( $row, 0, $title, $overrides );
return new Revision( $rec, self::READ_NORMAL, $title );
}
* @return Revision|null
*/
public function getPrevious() {
- $rec = self::getRevisionStore()->getPreviousRevision( $this->mRecord, $this->getTitle() );
- return $rec === null
- ? null
- : new Revision( $rec, self::READ_NORMAL, $this->getTitle() );
+ $rec = self::getRevisionStore()->getPreviousRevision( $this->mRecord );
+ return $rec === null ? null : new Revision( $rec );
}
/**
* @return Revision|null
*/
public function getNext() {
- $rec = self::getRevisionStore()->getNextRevision( $this->mRecord, $this->getTitle() );
- return $rec === null
- ? null
- : new Revision( $rec, self::READ_NORMAL, $this->getTitle() );
+ $rec = self::getRevisionStore()->getNextRevision( $this->mRecord );
+ return $rec === null ? null : new Revision( $rec );
}
/**
$cacheKey = isset( $row->old_id ) ? ( 'tt:' . $row->old_id ) : null;
- return self::getBlobStore()->expandBlob( $text, $flags, $cacheKey );
+ return self::getBlobStore( $wiki )->expandBlob( $text, $flags, $cacheKey );
}
/**
? $pageIdOrTitle
: Title::newFromID( $pageIdOrTitle );
+ if ( !$title ) {
+ return false;
+ }
+
$record = self::getRevisionStore()->getKnownCurrentRevision( $title, $revId );
return $record ? new Revision( $record ) : false;
}