r47215 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47214‎ | r47215 | r47216 >
Date:15:14, 13 February 2009
Author:catrope
Status:deferred
Tags:
Comment:
API: Fix up r47214, which strangely had no commit message
* Use + instead of array_merge(), the latter messes up keys
* Fix a fatal error ($result not an object)
* Fix an interesting mistake when calling addTables(): addTables('foo', 'bar') doesn't add both tables, but adds foo AS bar
* Fix warning about $row->pt_namespace not being set

Commit message for r47214:
API: Refactor ApiQueryInfo
* Move result generating code from execute() to extractPageInfo()
** Merge code for existing and missing titles
* Don't loop over existing and missing titles separately, but on both in one go
* Move protection query code from execute() to getProtectionInfo()
** Merge code for existing and missing titles here as well
* Move subjectid/talkid query code from execute() to getTSIDs()
* Document some functions
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryInfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryInfo.php
@@ -204,7 +204,7 @@
205205 $pageSet = $this->getPageSet();
206206 $this->titles = $pageSet->getGoodTitles();
207207 $this->missing = $pageSet->getMissingTitles();
208 - $this->everything = array_merge($this->titles, $this->missing);
 208+ $this->everything = $this->titles + $this->missing;
209209 $result = $this->getResult();
210210
211211 $this->pageRestrictions = $pageSet->getCustomField('page_restrictions');
@@ -283,7 +283,7 @@
284284 if (isset($this->protections[$title->getNamespace()][$title->getDBkey()]))
285285 $pageInfo['protection'] =
286286 $this->protections[$title->getNamespace()][$title->getDBkey()];
287 - $result->setIndexedTagName($pageInfo['protection'], 'pr');
 287+ $this->getResult()->setIndexedTagName($pageInfo['protection'], 'pr');
288288 }
289289 if($this->fld_talkid && isset($this->talkids[$title->getNamespace()][$title->getDBKey()]))
290290 $pageInfo['talkid'] = $this->talkids[$title->getNamespace()][$title->getDBKey()];
@@ -308,7 +308,7 @@
309309 $db = $this->getDB();
310310
311311 // Get normal protections for existing titles
312 - $this->addTables('page_restrictions', 'page');
 312+ $this->addTables(array('page_restrictions', 'page'));
313313 $this->addWhere('page_id=pr_page');
314314 $this->addFields(array('pr_page', 'pr_type', 'pr_level',
315315 'pr_expiry', 'pr_cascade', 'page_namespace',
@@ -401,7 +401,7 @@
402402 $res = $this->select(__METHOD__);
403403 while($row = $db->fetchObject($res)) {
404404 $source = Title::makeTitle($row->page_namespace, $row->page_title);
405 - $this->protections[$row->pt_namespace][$row->pt_title][] = array(
 405+ $this->protections[$row->tl_namespace][$row->tl_title][] = array(
406406 'type' => $row->pr_type,
407407 'level' => $row->pr_level,
408408 'expiry' => Block::decodeExpiry($row->pr_expiry, TS_ISO_8601),

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r47214catrope14:44, 13 February 2009

Status & tagging log