Add User to Title::userCan calls in api
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 22 Sep 2012 11:33:33 +0000 (13:33 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Sat, 22 Sep 2012 11:33:33 +0000 (13:33 +0200)
Change-Id: I86ee1398abe4a790796d61aba1e1739bc55e565b

includes/api/ApiQuery.php
includes/api/ApiQueryInfo.php
includes/api/ApiQueryRevisions.php

index 554aae5..64399b2 100644 (file)
@@ -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;
                                }
                        }
index 5d4f034..b617ed0 100644 (file)
@@ -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'] = '';
                }
 
index b89a8ea..41dfc33 100644 (file)
@@ -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' );