r22682 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22681‎ | r22682 | r22683 >
Date:17:22, 3 June 2007
Author:yurik
Status:old
Tags:
Comment:
API fixed bug 10112 generator=backlinks&prop=info broken
Modified paths:
  • /trunk/phase3/includes/api/ApiQuery.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryInfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQuery.php
@@ -164,22 +164,16 @@
165165 $this->InstantiateModules($modules, 'list', $this->mQueryListModules);
166166 $this->InstantiateModules($modules, 'meta', $this->mQueryMetaModules);
167167
168 - // Modules may optimize data requests through the $this->getPageSet() object
169 - // Execute all requested modules.
170 - foreach ($modules as $module) {
171 - $module->requestExtraData();
172 - }
173 -
174168 //
175 - // Populate page information for the given pageSet
176 - //
177 - $this->mPageSet->execute();
178 -
179 - //
180169 // If given, execute generator to substitute user supplied data with generated data.
181170 //
182 - if (isset ($this->params['generator']))
183 - $this->executeGeneratorModule($this->params['generator']);
 171+ if (isset ($this->params['generator'])) {
 172+ $this->executeGeneratorModule($this->params['generator'], $modules);
 173+ } else {
 174+ // Append custom fields and populate page/revision information
 175+ $this->addCustomFldsToPageSet($modules, $this->mPageSet);
 176+ $this->mPageSet->execute();
 177+ }
184178
185179 //
186180 // Record page information (title, namespace, if exists, etc)
@@ -195,6 +189,18 @@
196190 $module->profileOut();
197191 }
198192 }
 193+
 194+ /**
 195+ * Query modules may optimize data requests through the $this->getPageSet() object
 196+ * by adding extra fields from the page table.
 197+ * This function will gather all the extra request fields from the modules.
 198+ */
 199+ private function addCustomFldsToPageSet($modules, $pageSet) {
 200+ // Query all requested modules.
 201+ foreach ($modules as $module) {
 202+ $module->requestExtraData($pageSet);
 203+ }
 204+ }
199205
200206 /**
201207 * Create instances of all modules requested by the client
@@ -206,6 +212,10 @@
207213 $modules[] = new $moduleList[$moduleName] ($this, $moduleName);
208214 }
209215
 216+ /**
 217+ * Appends an element for each page in the current pageSet with the most general
 218+ * information (id, title), plus any title normalizations and missing title/pageids/revids.
 219+ */
210220 private function outputGeneralPageInfo() {
211221
212222 $pageSet = $this->getPageSet();
@@ -299,7 +309,10 @@
300310 }
301311 }
302312
303 - protected function executeGeneratorModule($generatorName) {
 313+ /**
 314+ * For generator mode, execute generator, and use its output as new pageSet
 315+ */
 316+ protected function executeGeneratorModule($generatorName, $modules) {
304317
305318 // Find class that implements requested generator
306319 if (isset ($this->mQueryListModules[$generatorName])) {
@@ -319,8 +332,14 @@
320333 $this->dieUsage("Module $generatorName cannot be used as a generator", "badgenerator");
321334
322335 $generator->setGeneratorMode();
323 - $generator->requestExtraData();
324336
 337+ // Add any additional fields modules may need
 338+ $generator->requestExtraData($this->mPageSet);
 339+ $this->addCustomFldsToPageSet($modules, $resultPageSet);
 340+
 341+ // Populate page information with the original user input
 342+ $this->mPageSet->execute();
 343+
325344 // populate resultPageSet with the generator output
326345 $generator->profileIn();
327346 $generator->executeGenerator($resultPageSet);
@@ -380,6 +399,9 @@
381400 return $msg;
382401 }
383402
 403+ /**
 404+ * For all modules in $moduleList, generate help messages and join them together
 405+ */
384406 private function makeHelpMsgHelper($moduleList, $paramName) {
385407
386408 $moduleDscriptions = array ();
Index: trunk/phase3/includes/api/ApiQueryBase.php
@@ -139,9 +139,9 @@
140140
141141 /**
142142 * Override this method to request extra fields from the pageSet
143 - * using $this->getPageSet()->requestField('fieldName')
 143+ * using $pageSet->requestField('fieldName')
144144 */
145 - public function requestExtraData() {
 145+ public function requestExtraData($pageSet) {
146146 }
147147
148148 /**
Index: trunk/phase3/includes/api/ApiQueryInfo.php
@@ -39,8 +39,7 @@
4040 parent :: __construct($query, $moduleName);
4141 }
4242
43 - public function requestExtraData() {
44 - $pageSet = $this->getPageSet();
 43+ public function requestExtraData($pageSet) {
4544 $pageSet->requestField('page_is_redirect');
4645 $pageSet->requestField('page_is_new');
4746 $pageSet->requestField('page_counter');

Follow-up revisions

RevisionCommit summaryAuthorDate
r22717Merged revisions 22667-22715 via svnmerge from...david20:00, 4 June 2007

Status & tagging log