r62544 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62543‎ | r62544 | r62545 >
Date:20:42, 15 February 2010
Author:catrope
Status:ok
Tags:
Comment:
API: Redo r62540 for all modules, easier than I first imagined
Modified paths:
  • /trunk/phase3/includes/api/ApiMain.php (modified) (history)
  • /trunk/phase3/includes/api/ApiOpenSearch.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiMain.php
@@ -432,8 +432,8 @@
433433 }
434434 }
435435
436 - global $wgUser;
437 - if ( $module->isReadMode() && !$wgUser->isAllowed( 'read' ) )
 436+ global $wgUser, $wgGroupPermissions;
 437+ if ( $module->isReadMode() && !$wgGroupPermissions['*']['read'] && !$wgUser->isAllowed( 'read' ) )
438438 $this->dieUsageMsg( array( 'readrequired' ) );
439439 if ( $module->isWriteMode() ) {
440440 if ( !$this->mEnableWrite )
Index: trunk/phase3/includes/api/ApiOpenSearch.php
@@ -42,15 +42,15 @@
4343 }
4444
4545 public function execute() {
46 - global $wgEnableOpenSearchSuggest, $wgSearchSuggestCacheExpiry, $wgGroupPermissions, $wgUser;
 46+ global $wgEnableOpenSearchSuggest, $wgSearchSuggestCacheExpiry;
4747 $params = $this->extractRequestParams();
4848 $search = $params['search'];
4949 $limit = $params['limit'];
5050 $namespaces = $params['namespace'];
5151 $suggest = $params['suggest'];
5252
53 - // MWSuggest or similar hit, or hit without read rights
54 - if ( ( $suggest && !$wgEnableOpenSearchSuggest ) || ( !$wgGroupPermissions['*']['read'] && !$wgUser->isAllowed( 'read' ) ) )
 53+ // MWSuggest or similar hit
 54+ if ( $suggest && !$wgEnableOpenSearchSuggest )
5555 $srchres = array();
5656 else {
5757 // Open search results may be stored for a very long
@@ -108,8 +108,4 @@
109109 public function getVersion() {
110110 return __CLASS__ . ': $Id$';
111111 }
112 -
113 - public function isReadMode() {
114 - return false;
115 - }
116112 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r62540API: Optimize read rights check in opensearch so $wgUser doesn't get unstubbe...catrope20:20, 15 February 2010

Status & tagging log