API: Fix up r47214, which strangely had no commit message
authorRoan Kattouw <catrope@users.mediawiki.org>
Fri, 13 Feb 2009 15:14:21 +0000 (15:14 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Fri, 13 Feb 2009 15:14:21 +0000 (15:14 +0000)
* 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

includes/api/ApiQueryInfo.php

index 86a6af7..ce5d2ac 100644 (file)
@@ -204,7 +204,7 @@ class ApiQueryInfo extends ApiQueryBase {
                $pageSet = $this->getPageSet();
                $this->titles = $pageSet->getGoodTitles();
                $this->missing = $pageSet->getMissingTitles();
-               $this->everything = array_merge($this->titles, $this->missing);
+               $this->everything = $this->titles + $this->missing;
                $result = $this->getResult();
 
                $this->pageRestrictions = $pageSet->getCustomField('page_restrictions');
@@ -283,7 +283,7 @@ class ApiQueryInfo extends ApiQueryBase {
                        if (isset($this->protections[$title->getNamespace()][$title->getDBkey()])) 
                                $pageInfo['protection'] =
                                        $this->protections[$title->getNamespace()][$title->getDBkey()];
-                       $result->setIndexedTagName($pageInfo['protection'], 'pr');
+                       $this->getResult()->setIndexedTagName($pageInfo['protection'], 'pr');
                }
                if($this->fld_talkid && isset($this->talkids[$title->getNamespace()][$title->getDBKey()]))
                        $pageInfo['talkid'] = $this->talkids[$title->getNamespace()][$title->getDBKey()];
@@ -308,7 +308,7 @@ class ApiQueryInfo extends ApiQueryBase {
                $db = $this->getDB();
 
                // Get normal protections for existing titles
-               $this->addTables('page_restrictions', 'page');
+               $this->addTables(array('page_restrictions', 'page'));
                $this->addWhere('page_id=pr_page');
                $this->addFields(array('pr_page', 'pr_type', 'pr_level',
                                'pr_expiry', 'pr_cascade', 'page_namespace',
@@ -401,7 +401,7 @@ class ApiQueryInfo extends ApiQueryBase {
                        $res = $this->select(__METHOD__);
                        while($row = $db->fetchObject($res)) {
                                $source = Title::makeTitle($row->page_namespace, $row->page_title);
-                               $this->protections[$row->pt_namespace][$row->pt_title][] = array(
+                               $this->protections[$row->tl_namespace][$row->tl_title][] = array(
                                        'type' => $row->pr_type,
                                        'level' => $row->pr_level,
                                        'expiry' => Block::decodeExpiry($row->pr_expiry, TS_ISO_8601),