+ /**
+ * MCR RevisionStore Compat
+ *
+ * If the title is not passed in as a param (already known) then select it here.
+ *
+ * Do the selection with MASTER if $flags includes READ_LATEST or recent changes
+ * have happened on our load balancer.
+ *
+ * If we select the title here and pass it down it will results in fewer queries
+ * further down the stack.
+ */
+ if ( !$title ) {
+ if (
+ $flags & self::READ_LATEST ||
+ wfGetLB()->hasOrMadeRecentMasterChanges()
+ ) {
+ $dbr = wfGetDB( DB_MASTER );
+ } else {
+ $dbr = wfGetDB( DB_REPLICA );
+ }
+ $row = $dbr->selectRow(
+ [ 'revision', 'page' ],
+ [
+ 'page_namespace',
+ 'page_title',
+ 'page_id',
+ 'page_latest',
+ 'page_is_redirect',
+ 'page_len',
+ ],
+ [ 'rev_id' => $id ],
+ __METHOD__,
+ [],
+ [ 'page' => [ 'JOIN', 'page_id=rev_page' ] ]
+ );
+ if ( $row ) {
+ $title = Title::newFromRow( $row );
+ }
+ wfGetLB()->reuseConnection( $dbr );
+ }
+