From a70ec0e7c8617a470dd96ab6e46792f0638e3278 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Mon, 21 May 2007 00:10:01 +0000 Subject: [PATCH] API: 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) --- RELEASE-NOTES | 2 ++ includes/api/ApiQueryBacklinks.php | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 5be3e01176..e3b11d7788 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php index 7edfa60520..4aec802e8f 100644 --- a/includes/api/ApiQueryBacklinks.php +++ b/includes/api/ApiQueryBacklinks.php @@ -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(); -- 2.20.1