* @return RevisionRecord|null
*/
public function getRevisionByTitle( LinkTarget $linkTarget, $revId = 0, $flags = 0 ) {
+ // TODO should not require Title in future (T206498)
+ $title = Title::newFromLinkTarget( $linkTarget );
$conds = [
- 'page_namespace' => $linkTarget->getNamespace(),
- 'page_title' => $linkTarget->getDBkey()
+ 'page_namespace' => $title->getNamespace(),
+ 'page_title' => $title->getDBkey()
];
if ( $revId ) {
// Use the specified revision ID.
// Since the caller supplied a revision ID, we are pretty sure the revision is
// supposed to exist, so we should try hard to find it.
$conds['rev_id'] = $revId;
- return $this->newRevisionFromConds( $conds, $flags );
+ return $this->newRevisionFromConds( $conds, $flags, $title );
} else {
// Use a join to get the latest revision.
// Note that we don't use newRevisionFromConds here because we don't want to retry
$db = $this->getDBConnectionRefForQueryFlags( $flags );
$conds[] = 'rev_id=page_latest';
- $rev = $this->loadRevisionFromConds( $db, $conds, $flags );
+ $rev = $this->loadRevisionFromConds( $db, $conds, $flags, $title );
return $rev;
}
) {
if ( !$this->hasMcrSchemaFlags( SCHEMA_COMPAT_READ_NEW ) ) {
$mainSlot = $this->emulateMainSlot_1_29( $revisionRow, $queryFlags, $title );
+ // @phan-suppress-next-line PhanTypeInvalidCallableArraySize false positive
$slots = new RevisionSlots( [ SlotRecord::MAIN => $mainSlot ] );
} else {
// XXX: do we need the same kind of caching here
}
// if we have a content object, use it to set the model and type
- if ( !empty( $fields['content'] ) ) {
- if ( !( $fields['content'] instanceof Content ) && !is_array( $fields['content'] ) ) {
- throw new MWException(
- 'content field must contain a Content object or an array of Content objects.'
- );
- }
+ if ( !empty( $fields['content'] ) && !( $fields['content'] instanceof Content )
+ && !is_array( $fields['content'] )
+ ) {
+ throw new MWException(
+ 'content field must contain a Content object or an array of Content objects.'
+ );
}
if ( !empty( $fields['text_id'] ) ) {