r97303 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97302‎ | r97303 | r97304 >
Date:18:11, 16 September 2011
Author:reedy
Status:ok
Tags:
Comment:
Give a list of modules to query and action into paraminfo
Modified paths:
  • /trunk/phase3/includes/api/ApiParamInfo.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQuery.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQuery.php
@@ -179,7 +179,7 @@
180180
181181 /**
182182 * Get the array mapping module names to class names
183 - * @return array(modulename => classname)
 183+ * @return array (modulename => classname)
184184 */
185185 function getModules() {
186186 return array_merge( $this->mQueryPropModules, $this->mQueryListModules, $this->mQueryMetaModules );
Index: trunk/phase3/includes/api/ApiParamInfo.php
@@ -34,15 +34,21 @@
3535 */
3636 class ApiParamInfo extends ApiBase {
3737
 38+ /**
 39+ * @var ApiQuery
 40+ */
 41+ protected $queryObj;
 42+
3843 public function __construct( $main, $action ) {
3944 parent::__construct( $main, $action );
 45+ $this->queryObj = new ApiQuery( $this->getMain(), 'query' );
4046 }
4147
4248 public function execute() {
4349 // Get parameters
4450 $params = $this->extractRequestParams();
4551 $result = $this->getResult();
46 - $queryObj = new ApiQuery( $this->getMain(), 'query' );
 52+
4753 $r = array();
4854 if ( is_array( $params['modules'] ) ) {
4955 $modArr = $this->getMain()->getModules();
@@ -60,7 +66,7 @@
6167 $result->setIndexedTagName( $r['modules'], 'module' );
6268 }
6369 if ( is_array( $params['querymodules'] ) ) {
64 - $qmodArr = $queryObj->getModules();
 70+ $qmodArr = $this->queryObj->getModules();
6571 $r['querymodules'] = array();
6672 foreach ( $params['querymodules'] as $qm ) {
6773 if ( !isset( $qmodArr[$qm] ) ) {
@@ -70,7 +76,7 @@
7177 $obj = new $qmodArr[$qm]( $this, $qm );
7278 $a = $this->getClassInfo( $obj );
7379 $a['name'] = $qm;
74 - $a['querytype'] = $queryObj->getModuleType( $qm );
 80+ $a['querytype'] = $this->queryObj->getModuleType( $qm );
7581 $r['querymodules'][] = $a;
7682 }
7783 $result->setIndexedTagName( $r['querymodules'], 'module' );
@@ -79,7 +85,7 @@
8086 $r['mainmodule'] = $this->getClassInfo( $this->getMain() );
8187 }
8288 if ( $params['pagesetmodule'] ) {
83 - $pageSet = new ApiPageSet( $queryObj );
 89+ $pageSet = new ApiPageSet( $this->queryObj );
8490 $r['pagesetmodule'] = $this->getClassInfo( $pageSet );
8591 }
8692 $result->addValue( null, $this->getModuleName(), $r );
@@ -219,12 +225,15 @@
220226 }
221227
222228 public function getAllowedParams() {
 229+
223230 return array(
224231 'modules' => array(
225 - ApiBase::PARAM_ISMULTI => true
 232+ ApiBase::PARAM_ISMULTI => true,
 233+ ApiBase::PARAM_TYPE => array_keys( $this->getMain()->getModules() ),
226234 ),
227235 'querymodules' => array(
228 - ApiBase::PARAM_ISMULTI => true
 236+ ApiBase::PARAM_ISMULTI => true,
 237+ ApiBase::PARAM_TYPE => array_keys( $this->queryObj->getModules() ),
229238 ),
230239 'mainmodule' => false,
231240 'pagesetmodule' => false,

Sign-offs

UserFlagDate
Krinkleinspected22:33, 18 September 2011
Krinkletested22:33, 18 September 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r106763Follow-up r97303: sort module names in paraminfo's paraminfomaxsem07:50, 20 December 2011

Status & tagging log