r47514 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47513‎ | r47514 | r47515 >
Date:21:24, 19 February 2009
Author:catrope
Status:ok
Tags:
Comment:
API: (bug 17563) Fix regression from r46845 that changed the output for list=backlinks to use page IDs as array indexes instead of 0,1,2,... (which makes a big difference in JSON and breaks clients) and caused weird output for generator=backlinks as well. Patch by Brad Jorsch
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryBacklinks.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryBacklinks.php
@@ -240,53 +240,53 @@
241241 }
242242 $db->freeResult($res);
243243 }
244 - // Try to add the result data in one go and pray that it fits
245 - $fit = $this->getResult()->addValue('query', $this->getModuleName(), $this->resultArr);
246 - if(!$fit)
247 - {
248 - // It didn't fit. Add elements one by one until the
249 - // result is full.
250 - foreach($this->resultArr as $pageID => $arr)
 244+ if (is_null($resultPageSet)) {
 245+ // Try to add the result data in one go and pray that it fits
 246+ $fit = $this->getResult()->addValue('query', $this->getModuleName(), array_values($this->resultArr));
 247+ if(!$fit)
251248 {
252 - // Add the basic entry without redirlinks first
253 - $fit = $this->getResult()->addValue(
254 - array('query', $this->getModuleName()),
255 - $pageID, array_diff_key($arr, array('redirlinks' => '')));
256 - if(!$fit)
 249+ // It didn't fit. Add elements one by one until the
 250+ // result is full.
 251+ foreach($this->resultArr as $pageID => $arr)
257252 {
258 - $this->continueStr = $this->getContinueStr($pageID);
259 - break;
260 - }
261 -
262 - $hasRedirs = false;
263 - foreach((array)@$arr['redirlinks'] as $key => $redir)
264 - {
 253+ // Add the basic entry without redirlinks first
265254 $fit = $this->getResult()->addValue(
266 - array('query', $this->getModuleName(), $pageID, 'redirlinks'),
267 - $key, $redir);
 255+ array('query', $this->getModuleName()),
 256+ null, array_diff_key($arr, array('redirlinks' => '')));
268257 if(!$fit)
269258 {
270 - $this->continueStr = $this->getContinueRedirStr($pageID, $redir['pageid']);
 259+ $this->continueStr = $this->getContinueStr($pageID);
271260 break;
272261 }
273 - $hasRedirs = true;
 262+
 263+ $hasRedirs = false;
 264+ foreach((array)@$arr['redirlinks'] as $key => $redir)
 265+ {
 266+ $fit = $this->getResult()->addValue(
 267+ array('query', $this->getModuleName(), $pageID, 'redirlinks'),
 268+ $key, $redir);
 269+ if(!$fit)
 270+ {
 271+ $this->continueStr = $this->getContinueRedirStr($pageID, $redir['pageid']);
 272+ break;
 273+ }
 274+ $hasRedirs = true;
 275+ }
 276+ if($hasRedirs)
 277+ $this->getResult()->setIndexedTagName_internal(
 278+ array('query', $this->getModuleName(), $pageID, 'redirlinks'),
 279+ $this->bl_code);
 280+ if(!$fit)
 281+ break;
274282 }
275 - if($hasRedirs)
276 - $this->getResult()->setIndexedTagName_internal(
277 - array('query', $this->getModuleName(), $pageID, 'redirlinks'),
278 - $this->bl_code);
279 - if(!$fit)
280 - break;
281 - }
282 - }
283 - if(!is_null($this->continueStr))
284 - $this->setContinueEnumParameter('continue', $this->continueStr);
 283+ }
285284
286 - if (is_null($resultPageSet)) {
287285 $this->getResult()->setIndexedTagName_internal(
288286 array('query', $this->getModuleName()),
289287 $this->bl_code);
290288 }
 289+ if(!is_null($this->continueStr))
 290+ $this->setContinueEnumParameter('continue', $this->continueStr);
291291 }
292292
293293 private function extractRowInfo($row) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r46845* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in so...catrope14:30, 5 February 2009

Status & tagging log