r44900 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44899‎ | r44900 | r44901 >
Date:14:43, 22 December 2008
Author:ialex
Status:ok
Tags:
Comment:
Per catrope's commit message on r44894: Missing rights while executing API module now result in warnings rather than errors.
Modified paths:
  • /trunk/extensions/Configure/CHANGELOG (modified) (history)
  • /trunk/extensions/Configure/Configure.api.php (modified) (history)
  • /trunk/extensions/Configure/Configure.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Configure/Configure.api.php
@@ -19,104 +19,112 @@
2020 $prop = array_flip( $params['prop'] );
2121 // Version list
2222 if ( isset( $prop['versionlist'] ) ) {
23 - if ( !$wgUser->isAllowed( 'viewconfig' ) )
24 - $this->dieUsage( 'viewconfig right required', 'noright' );
25 - $versions = $wgConf->listArchiveVersions();
26 - if ( $wgUser->isAllowed( 'viewconfig-interwiki' ) ) {
27 - $oldVersions = $versions;
28 - $versions = array();
29 - foreach ( $oldVersions as $version ) {
30 - $settings = $wgConf->getOldSettings( $version );
31 - $wikis = array_keys( $settings );
32 - $wikis['id'] = $version;
33 - $result->setIndexedTagName( $wikis, 'wiki' );
34 - $versions[] = $wikis;
 23+ if ( $wgUser->isAllowed( 'viewconfig' ) ) {
 24+ $versions = $wgConf->listArchiveVersions();
 25+ if ( $wgUser->isAllowed( 'viewconfig-interwiki' ) ) {
 26+ $oldVersions = $versions;
 27+ $versions = array();
 28+ foreach ( $oldVersions as $version ) {
 29+ $settings = $wgConf->getOldSettings( $version );
 30+ $wikis = array_keys( $settings );
 31+ $wikis['id'] = $version;
 32+ $result->setIndexedTagName( $wikis, 'wiki' );
 33+ $versions[] = $wikis;
 34+ }
3535 }
 36+ $result->setIndexedTagName( $versions, 'version' );
 37+ $result->addValue( $this->getModuleName(), 'versions', $versions );
 38+ } else {
 39+ $this->setWarning( '`viewconfig\' right is required to use `versionlist\'' );
3640 }
37 - $result->setIndexedTagName( $versions, 'version' );
38 - $result->addValue( $this->getModuleName(), 'versions', $versions );
3941 }
4042
4143 // Wiki list
4244 if ( isset( $prop['wikilist'] ) ) {
43 - if ( !$wgUser->isAllowed( 'viewconfig-interwiki' ) )
44 - $this->dieUsage( 'viewconfig-interwiki right required', 'noright' );
45 - if ( $wgConfigureWikis === false )
46 - $result->addValue( 'configure', 'wikis', array( 'denied' => '' ) );
47 - if ( $wgConfigureWikis === true )
48 - $result->addValue( 'configure', 'wikis', array( 'any' => '' ) );
49 - if ( is_array( $wgConfigureWikis ) ) {
50 - $wikis = $wgConfigureWikis;
51 - $result->setIndexedTagName( $wikis, 'wiki' );
52 - $result->addValue( $this->getModuleName(), 'wikis', $wikis );
 45+ if ( $wgUser->isAllowed( 'viewconfig-interwiki' ) ) {
 46+ if ( $wgConfigureWikis === false )
 47+ $result->addValue( 'configure', 'wikis', array( 'denied' => '' ) );
 48+ if ( $wgConfigureWikis === true )
 49+ $result->addValue( 'configure', 'wikis', array( 'any' => '' ) );
 50+ if ( is_array( $wgConfigureWikis ) ) {
 51+ $wikis = $wgConfigureWikis;
 52+ $result->setIndexedTagName( $wikis, 'wiki' );
 53+ $result->addValue( $this->getModuleName(), 'wikis', $wikis );
 54+ }
 55+ } else {
 56+ $this->setWarning( '`viewconfig-interwiki\' right is required to use `wikilist\'' );
5357 }
5458 }
5559
5660 // Settings
5761 if ( isset( $prop['settings'] ) ) {
58 - if ( !$wgUser->isAllowed( 'viewconfig' ) )
59 - $this->dieUsage( 'viewconfig right required', 'noright' );
60 - $version = $params['version'];
61 - $wiki = $params['wiki'] ? $params['wiki'] : $wgConf->getWiki();
62 - $settingsValues = $wgConf->getOldSettings( $version );
63 - if ( !is_array( $settingsValues ) )
64 - $this->dieUsage( 'version not found', 'noversion' );
65 - if ( !isset( $settingsValues[$wiki] ) || !is_array( $settingsValues[$wiki] ) )
66 - $this->dieUsage( 'wiki not found in version', 'nowiki' );
67 - $settingsValues = $settingsValues[$wiki];
68 - $conf = ConfigurationSettings::singleton( CONF_SETTINGS_BOTH );
69 - $notEditable = $conf->getUneditableSettings();
70 - $ret = array();
71 - if ( $params['group'] ) {
72 - $sections = $conf->getSettings();
73 - foreach ( $sections as $sectionName => $section ) {
74 - $groupRet = array( 'name' => $sectionName );
75 - foreach ( $section as $groupName => $group ) {
76 - $settingsRet = array( 'name' => $groupName );
77 - foreach ( $group as $setting => $type ) {
78 - if ( !$conf->isSettingAvailable( $setting ) || in_array( $setting, $notEditable ) )
79 - continue;
80 - $settingsRet[] = $this->getSettingResult( $setting, $type, $settingsValues, $conf, $result );
 62+ if ( $wgUser->isAllowed( 'viewconfig' ) ) {
 63+ $version = $params['version'];
 64+ $wiki = $params['wiki'] ? $params['wiki'] : $wgConf->getWiki();
 65+ $settingsValues = $wgConf->getOldSettings( $version );
 66+ if ( !is_array( $settingsValues ) )
 67+ $this->dieUsage( 'version not found', 'noversion' );
 68+ if ( !isset( $settingsValues[$wiki] ) || !is_array( $settingsValues[$wiki] ) )
 69+ $this->dieUsage( 'wiki not found in version', 'nowiki' );
 70+ $settingsValues = $settingsValues[$wiki];
 71+ $conf = ConfigurationSettings::singleton( CONF_SETTINGS_BOTH );
 72+ $notEditable = $conf->getUneditableSettings();
 73+ $ret = array();
 74+ if ( $params['group'] ) {
 75+ $sections = $conf->getSettings();
 76+ foreach ( $sections as $sectionName => $section ) {
 77+ $groupRet = array( 'name' => $sectionName );
 78+ foreach ( $section as $groupName => $group ) {
 79+ $settingsRet = array( 'name' => $groupName );
 80+ foreach ( $group as $setting => $type ) {
 81+ if ( !$conf->isSettingAvailable( $setting ) || in_array( $setting, $notEditable ) )
 82+ continue;
 83+ $settingsRet[] = $this->getSettingResult( $setting, $type, $settingsValues, $conf, $result );
 84+ }
 85+ $result->setIndexedTagName( $settingsRet, 'setting' );
 86+ $groupRet[] = $settingsRet;
8187 }
82 - $result->setIndexedTagName( $settingsRet, 'setting' );
83 - $groupRet[] = $settingsRet;
 88+ $result->setIndexedTagName( $groupRet, 'group' );
 89+ $ret[] = $groupRet;
8490 }
85 - $result->setIndexedTagName( $groupRet, 'group' );
86 - $ret[] = $groupRet;
 91+ $result->setIndexedTagName( $ret, 'section' );
 92+ } else {
 93+ $settings = $conf->getAllSettings();
 94+ foreach ( $settings as $setting => $type ) {
 95+ if ( !$conf->isSettingAvailable( $setting ) || in_array( $setting, $notEditable ) )
 96+ continue;
 97+ $ret[] = $this->getSettingResult( $setting, $type, $settingsValues, $conf, $result );
 98+ }
 99+ $result->setIndexedTagName( $ret, 'setting' );
87100 }
88 - $result->setIndexedTagName( $ret, 'section' );
 101+ $result->addValue( $this->getModuleName(), 'settings', $ret );
89102 } else {
90 - $settings = $conf->getAllSettings();
91 - foreach ( $settings as $setting => $type ) {
92 - if ( !$conf->isSettingAvailable( $setting ) || in_array( $setting, $notEditable ) )
93 - continue;
94 - $ret[] = $this->getSettingResult( $setting, $type, $settingsValues, $conf, $result );
95 - }
96 - $result->setIndexedTagName( $ret, 'setting' );
 103+ $this->setWarning( '`viewconfig\' right is required to use `settings\'' );
97104 }
98 - $result->addValue( $this->getModuleName(), 'settings', $ret );
99105 }
100106
101107 // Extensions
102108 if ( isset( $prop['extensions'] ) ) {
103 - if ( !$wgUser->isAllowed( 'extensions' ) )
104 - $this->dieUsage( 'extensions right required', 'noright' );
105 - $conf = ConfigurationSettings::singleton( CONF_SETTINGS_EXT );
106 - $ret = array();
107 - foreach ( $conf->getAllExtensionsObjects() as $ext ) {
108 - if( !$ext->isInstalled() ) continue; // must exist
109 - $extArr = array();
110 - $extArr['name'] = $ext->getName();
111 - if ( $ext->isActivated() )
112 - $extArr['activated'] = '';
113 - if ( $ext->hasSchemaChange() )
114 - $extArr['schema'] = '';
115 - if ( ( $url = $ext->getUrl() ) !== null )
116 - $extArr['url'] = $url;
117 - $ret[] = $extArr;
 109+ if ( $wgUser->isAllowed( 'extensions' ) ) {
 110+ $conf = ConfigurationSettings::singleton( CONF_SETTINGS_EXT );
 111+ $ret = array();
 112+ foreach ( $conf->getAllExtensionsObjects() as $ext ) {
 113+ if( !$ext->isInstalled() ) continue; // must exist
 114+ $extArr = array();
 115+ $extArr['name'] = $ext->getName();
 116+ if ( $ext->isActivated() )
 117+ $extArr['activated'] = '';
 118+ if ( $ext->hasSchemaChange() )
 119+ $extArr['schema'] = '';
 120+ if ( ( $url = $ext->getUrl() ) !== null )
 121+ $extArr['url'] = $url;
 122+ $ret[] = $extArr;
 123+ }
 124+ $result->setIndexedTagName( $ret, 'extension' );
 125+ $result->addValue( $this->getModuleName(), 'extension', $ret );
 126+ } else {
 127+ $this->setWarning( '`extensions\' right is required to use `extensions\'' );
118128 }
119 - $result->setIndexedTagName( $ret, 'extension' );
120 - $result->addValue( $this->getModuleName(), 'extension', $ret );
121129 }
122130 }
123131
Index: trunk/extensions/Configure/CHANGELOG
@@ -1,6 +1,10 @@
22 This file lists changes on this extension.
33 Localisation updates are done on betawiki and aren't listed here.
44
 5+0.11.3 - 22 December 2008
 6+ Missing rights while executing API module now result in warnings rather than
 7+ errors.
 8+
59 0.11.2 - 18 December 2008
610 Added support for APCOND_ISIP and APCOND_IPINRANGE conditions of
711 $wgAutopromote.
Index: trunk/extensions/Configure/Configure.php
@@ -17,7 +17,7 @@
1818 'url' => 'http://www.mediawiki.org/wiki/Extension:Configure',
1919 'description' => 'Allow authorised users to configure the wiki via a web-based interface',
2020 'descriptionmsg' => 'configure-desc',
21 - 'version' => '0.11.2',
 21+ 'version' => '0.11.3',
2222 );
2323
2424 # Configuration part

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r44894Configure API:...catrope10:20, 22 December 2008

Status & tagging log