r44894 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44893‎ | r44894 | r44895 >
Date:10:20, 22 December 2008
Author:catrope
Status:deferred
Tags:
Comment:
Configure API:
* Use array_flip() and isset() rather than in_array()
* Use $this->getModuleName() rather than hardcoding 'configure' all over the place
* Fix weird indentation in getAllowedParams()
* It would be nice if this module threw a warning rather than an error when the user lacks permissions for one prop, so other props are unaffected
Modified paths:
  • /trunk/extensions/Configure/Configure.api.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Configure/Configure.api.php
@@ -16,8 +16,9 @@
1717 $this->dieUsage( 'You need to call efConfigureSetup() to use this module', 'noconf' );
1818 }
1919
 20+ $prop = array_flip( $params['prop'] );
2021 // Version list
21 - if ( in_array( 'versionlist', $params['prop'] ) ) {
 22+ if ( isset( $prop['versionlist'] ) ) {
2223 if ( !$wgUser->isAllowed( 'viewconfig' ) )
2324 $this->dieUsage( 'viewconfig right required', 'noright' );
2425 $versions = $wgConf->listArchiveVersions();
@@ -33,11 +34,11 @@
3435 }
3536 }
3637 $result->setIndexedTagName( $versions, 'version' );
37 - $result->addValue( 'configure', 'versions', $versions );
 38+ $result->addValue( $this->getModuleName(), 'versions', $versions );
3839 }
3940
4041 // Wiki list
41 - if ( in_array( 'wikilist', $params['prop'] ) ) {
 42+ if ( isset( $prop['wikilist'] ) ) {
4243 if ( !$wgUser->isAllowed( 'viewconfig-interwiki' ) )
4344 $this->dieUsage( 'viewconfig-interwiki right required', 'noright' );
4445 if ( $wgConfigureWikis === false )
@@ -47,12 +48,12 @@
4849 if ( is_array( $wgConfigureWikis ) ) {
4950 $wikis = $wgConfigureWikis;
5051 $result->setIndexedTagName( $wikis, 'wiki' );
51 - $result->addValue( 'configure', 'wikis', $wikis );
 52+ $result->addValue( $this->getModuleName(), 'wikis', $wikis );
5253 }
5354 }
5455
5556 // Settings
56 - if ( in_array( 'settings', $params['prop'] ) ) {
 57+ if ( isset( $prop['settings'] ) ) {
5758 if ( !$wgUser->isAllowed( 'viewconfig' ) )
5859 $this->dieUsage( 'viewconfig right required', 'noright' );
5960 $version = $params['version'];
@@ -93,11 +94,11 @@
9495 }
9596 $result->setIndexedTagName( $ret, 'setting' );
9697 }
97 - $result->addValue( 'configure', 'settings', $ret );
 98+ $result->addValue( $this->getModuleName(), 'settings', $ret );
9899 }
99100
100101 // Extensions
101 - if ( in_array( 'extensions', $params['prop'] ) ) {
 102+ if ( isset( $prop['extensions'] ) ) {
102103 if ( !$wgUser->isAllowed( 'extensions' ) )
103104 $this->dieUsage( 'extensions right required', 'noright' );
104105 $conf = ConfigurationSettings::singleton( CONF_SETTINGS_EXT );
@@ -115,7 +116,7 @@
116117 $ret[] = $extArr;
117118 }
118119 $result->setIndexedTagName( $ret, 'extension' );
119 - $result->addValue( 'configure', 'extension', $ret );
 120+ $result->addValue( $this->getModuleName(), 'extension', $ret );
120121 }
121122 }
122123
@@ -318,15 +319,15 @@
319320 protected function getAllowedParams() {
320321 return array(
321322 'prop' => array(
322 - ApiBase::PARAM_ISMULTI => true,
323 - ApiBase::PARAM_TYPE => array(
324 - 'versionlist',
325 - 'wikilist',
326 - 'settings',
327 - 'extensions',
 323+ ApiBase::PARAM_ISMULTI => true,
 324+ ApiBase::PARAM_TYPE => array(
 325+ 'versionlist',
 326+ 'wikilist',
 327+ 'settings',
 328+ 'extensions',
 329+ ),
 330+ ApiBase::PARAM_DFLT => 'versionlist|wikilist',
328331 ),
329 - ApiBase::PARAM_DFLT => 'versionlist|wikilist',
330 - ),
331332 'version' => null,
332333 'wiki' => null,
333334 'group' => false,

Follow-up revisions

RevisionCommit summaryAuthorDate
r44900Per catrope's commit message on r44894: Missing rights while executing API mo...ialex14:43, 22 December 2008

Status & tagging log