From eb41fc9dc1462f60844b84f86587bb326395a25f Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sat, 22 Sep 2012 13:33:33 +0200 Subject: [PATCH] Add User to Title::userCan calls in api Change-Id: I86ee1398abe4a790796d61aba1e1739bc55e565b --- includes/api/ApiQuery.php | 3 ++- includes/api/ApiQueryInfo.php | 2 +- includes/api/ApiQueryRevisions.php | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index 554aae5ae5..64399b2f3a 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -513,8 +513,9 @@ class ApiQuery extends ApiBase { $exportTitles = array(); $titles = $pageSet->getGoodTitles(); if ( count( $titles ) ) { + $user = $this->getUser(); foreach ( $titles as $title ) { - if ( $title->userCan( 'read' ) ) { + if ( $title->userCan( 'read', $user ) ) { $exportTitles[] = $title; } } diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index 5d4f0346ed..b617ed05d5 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -406,7 +406,7 @@ class ApiQueryInfo extends ApiQueryBase { $pageInfo['fullurl'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); $pageInfo['editurl'] = wfExpandUrl( $title->getFullURL( 'action=edit' ), PROTO_CURRENT ); } - if ( $this->fld_readable && $title->userCan( 'read' ) ) { + if ( $this->fld_readable && $title->userCan( 'read', $this->getUser() ) ) { $pageInfo['readable'] = ''; } diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php index b89a8ea983..41dfc33a5f 100644 --- a/includes/api/ApiQueryRevisions.php +++ b/includes/api/ApiQueryRevisions.php @@ -191,8 +191,9 @@ class ApiQueryRevisions extends ApiQueryBase { if ( isset( $prop['content'] ) || !is_null( $this->difftotext ) ) { // For each page we will request, the user must have read rights for that page + $user = $this->getUser(); foreach ( $pageSet->getGoodTitles() as $title ) { - if ( !$title->userCan( 'read' ) ) { + if ( !$title->userCan( 'read', $user ) ) { $this->dieUsage( 'The current user is not allowed to read ' . $title->getPrefixedText(), 'accessdenied' ); -- 2.20.1