API: breaking change: backlinks, embeddedin & imageusage now return lists in json...
authorYuri Astrakhan <yurik@users.mediawiki.org>
Mon, 21 May 2007 00:10:01 +0000 (00:10 +0000)
committerYuri Astrakhan <yurik@users.mediawiki.org>
Mon, 21 May 2007 00:10:01 +0000 (00:10 +0000)
RELEASE-NOTES
includes/api/ApiQueryBacklinks.php

index 5be3e01..e3b11d7 100644 (file)
@@ -102,6 +102,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
           rc_this_oldid (textid) is no longer accessible from query watchlist
 * action=usercontribs: additional filtering by ucshow=; selection of needed fields with ucprop=;
   the textid (rev_text_id) is no longer being exposed
+* breaking change: backlinks, embeddedin & imageusage now return lists in json instead of a map,
+                   and do not return anything when titles do not exist. (bug 9970)
 
 == Maintenance script changes since 1.10 ==
 
index 7edfa60..4aec802 100644 (file)
@@ -167,22 +167,35 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                        }
 
                        if (is_null($resultPageSet)) {
-                               $vals = $this->addRowInfo('page', $row);
+                               $vals = $this->extractRowInfo($row);
                                if ($vals)
-                                       $data[intval($row->page_id)] = $vals;
+                                       $data[] = $vals;
                        } else {
                                $resultPageSet->processDbRow($row);
                        }
                }
                $db->freeResult($res);
 
-               if (is_null($resultPageSet)) {
+               if (is_null($resultPageSet) && !empty($data)) {
                        $result = $this->getResult();
                        $result->setIndexedTagName($data, $this->bl_code);
                        $result->addValue('query', $this->getModuleName(), $data);
                }
        }
 
+       private function extractRowInfo($row) {
+
+               $title = Title :: makeTitle($row->page_namespace, $row->page_title);
+               if (!$title->userCanRead())
+                       return false;
+
+               $vals = array();
+               $vals['pageid'] = intval($row->page_id);
+               ApiQueryBase :: addTitleInfo($vals, $title);
+
+               return $vals;
+       }
+
        protected function processContinue($continue, $redirect) {
                $pageSet = $this->getPageSet();
                $count = $pageSet->getTitleCount();