r30074 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r30073‎ | r30074 | r30075 >
Date:18:40, 23 January 2008
Author:catrope
Status:old
Tags:
Comment:
API:
* Fixing buggy class instantiation in ApiParamInfo
* Adding getModules() method to ApiMain and ApiQuery
Modified paths:
  • /trunk/phase3/includes/api/ApiMain.php (modified) (history)
  • /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
@@ -147,6 +147,13 @@
148148 public function getPageSet() {
149149 return $this->mPageSet;
150150 }
 151+
 152+ /**
 153+ * Get the array mapping module names to class names
 154+ */
 155+ function getModules() {
 156+ return array_merge($this->mQueryPropModules, $this->mQueryListModules, $this->mQueryMetaModules);
 157+ }
151158
152159 /**
153160 * Query execution happens in the following steps:
Index: trunk/phase3/includes/api/ApiMain.php
@@ -570,6 +570,13 @@
571571 protected function addFormat( $fmtName, $fmtClass ) {
572572 $this->mFormats[$fmtName] = $fmtClass;
573573 }
 574+
 575+ /**
 576+ * Get the array mapping module names to class names
 577+ */
 578+ function getModules() {
 579+ return $this->mModules;
 580+ }
574581 }
575582
576583 /**
Index: trunk/phase3/includes/api/ApiParamInfo.php
@@ -43,30 +43,35 @@
4444 $result = $this->getResult();
4545 $r = array();
4646 if(is_array($params['modules']))
 47+ {
 48+ $modArr = $this->getMain()->getModules();
4749 foreach($params['modules'] as $m)
4850 {
49 - $className = "Api$m";
50 - if(!class_exists($className))
 51+ if(!isset($modArr[$m]))
5152 {
52 - $mods[$m] = array('missing' => '');
 53+ $r['modules'][$m] = array('missing' => '');
5354 continue;
5455 }
55 - $obj = new $className($this->getMain(), $m);
 56+ $obj = new $modArr[$m]($this->getMain(), $m);
5657 $r['modules'][$m] = $this->getClassInfo($obj);
5758 }
 59+ }
5860 if(is_array($params['querymodules']))
 61+ {
 62+ $queryObj = new ApiQuery($this->getMain(), 'query');
 63+ $qmodArr = $queryObj->getModules();
5964 foreach($params['querymodules'] as $qm)
6065 {
61 - $className = "ApiQuery$qm";
62 - if(!class_exists($className))
 66+ if(!isset($qmodArr[$qm]))
6367 {
64 - $qmods[$qm] = array('missing' => '');
 68+ $r['querymodules'][$qm] = array('missing' => '');
6569 continue;
6670 }
67 - $obj = new $className($this, $qm);
 71+ $obj = new $qmodArr[$qm]($this, $qm);
6872 $r['querymodules'][$qm] = $this->getClassInfo($obj);
6973 }
70 - $result->addValue( null, $this->getModuleName(), $r );
 74+ }
 75+ $result->addValue(null, $this->getModuleName(), $r);
7176 }
7277
7378 function getClassInfo($obj)

Status & tagging log