Avoid extra Title::newFromId calls in api modules with revisions

The query for revisions include fields from the page table,
so use it with Title::newFromRow and pass it to the revision store.
If missing the revision store is using Title::newFromId for each row

For prop=revisions the page must always selected

Change-Id: I31d85bcdcfcd29892e91bf4fe1d7ec27bd61e593
This commit is contained in:
Umherirrender 2019-10-10 20:32:39 +02:00
parent 9cffe816e2
commit 18a4584d17
3 changed files with 4 additions and 7 deletions

View file

@ -154,7 +154,7 @@ class ApiFeedContributions extends ApiBase {
if ( $title && $this->getPermissionManager()->userCan( 'read', $user, $title ) ) {
$date = $row->rev_timestamp;
$comments = $title->getTalkPage()->getFullURL();
$revision = $this->revisionStore->newRevisionFromRow( $row );
$revision = $this->revisionStore->newRevisionFromRow( $row, 0, $title );
return new FeedItem(
$title->getPrefixedText(),

View file

@ -218,7 +218,7 @@ class ApiQueryAllRevisions extends ApiQueryRevisionsBase {
$generated[] = $row->rev_id;
}
} else {
$revision = $revisionStore->newRevisionFromRow( $row );
$revision = $revisionStore->newRevisionFromRow( $row, 0, Title::newFromRow( $row ) );
$rev = $this->extractRevisionInfo( $revision, $row );
if ( !isset( $pageMap[$row->rev_page] ) ) {

View file

@ -146,10 +146,7 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase {
if ( $resultPageSet === null ) {
$this->parseParameters( $params );
$this->token = $params['token'];
$opts = [];
if ( $this->token !== null || $pageCount > 0 ) {
$opts[] = 'page';
}
$opts = [ 'page' ];
if ( $this->fld_user ) {
$opts[] = 'user';
}
@ -417,7 +414,7 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase {
if ( $resultPageSet !== null ) {
$generated[] = $row->rev_id;
} else {
$revision = $revisionStore->newRevisionFromRow( $row );
$revision = $revisionStore->newRevisionFromRow( $row, 0, Title::newFromRow( $row ) );
$rev = $this->extractRevisionInfo( $revision, $row );
if ( $this->token !== null ) {