r34392 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34391‎ | r34392 | r34393 >
Date:19:15, 7 May 2008
Author:catrope
Status:old
Tags:
Comment:
(bug 14018) Added alcontinue parameter to list=alllinks to improve paging; used to cause an infinite loop when a lot of links to the same title (e.g. [[Wiki]] on enwiki, more than 500 links) were listed. This basically adds the page ID to the continue value, making it unique. Also killed another useless ORDER BY pl_namespace
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllLinks.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryAllLinks.php
@@ -66,6 +66,18 @@
6767
6868 $this->addTables('pagelinks');
6969 $this->addWhereFld('pl_namespace', $params['namespace']);
 70+
 71+ if (!is_null($params['from']) && !is_null($params['continue']))
 72+ $this->dieUsage('alcontinue and alfrom cannot be used together', 'params');
 73+ if (!is_null($params['continue']))
 74+ {
 75+ $arr = explode('|', $params['continue']);
 76+ if(count($arr) != 2)
 77+ $this->dieUsage("Invalid continue parameter", 'badcontinue');
 78+ $params['from'] = $arr[0]; // Handled later
 79+ $id = intval($arr[1]);
 80+ $this->addWhere("pl_from >= $id");
 81+ }
7082
7183 if (!is_null($params['from']))
7284 $this->addWhere('pl_title>=' . $db->addQuotes(ApiQueryBase :: titleToKey($params['from'])));
@@ -75,9 +87,9 @@
7688 if (is_null($resultPageSet)) {
7789 $this->addFields(array (
7890 'pl_namespace',
79 - 'pl_title'
 91+ 'pl_title',
 92+ 'pl_from'
8093 ));
81 - $this->addFieldsIf('pl_from', $fld_ids);
8294 } else {
8395 $this->addFields('pl_from');
8496 $pageids = array();
@@ -86,7 +98,7 @@
8799 $this->addOption('USE INDEX', 'pl_namespace');
88100 $limit = $params['limit'];
89101 $this->addOption('LIMIT', $limit+1);
90 - $this->addOption('ORDER BY', 'pl_namespace, pl_title');
 102+ $this->addOption('ORDER BY', 'pl_title');
91103
92104 $res = $this->select(__METHOD__);
93105
@@ -96,7 +108,7 @@
97109 if (++ $count > $limit) {
98110 // We've reached the one extra which shows that there are additional pages to be had. Stop here...
99111 // TODO: Security issue - if the user has no right to view next title, it will still be shown
100 - $this->setContinueEnumParameter('from', ApiQueryBase :: keyToTitle($row->pl_title));
 112+ $this->setContinueEnumParameter('continue', ApiQueryBase :: keyToTitle($row->pl_title) . "|" . $row->pl_from);
101113 break;
102114 }
103115
@@ -127,6 +139,7 @@
128140
129141 public function getAllowedParams() {
130142 return array (
 143+ 'continue' => null,
131144 'from' => null,
132145 'prefix' => null,
133146 'unique' => false,
Index: trunk/phase3/RELEASE-NOTES
@@ -314,6 +314,7 @@
315315 * (bug 13945) Retrieve cascading protection sources via inprop=protection
316316 * (bug 13965) Hardcoded 51 limit on titles is too limiting
317317 * (bug 13993) apfrom doesn't work with apdir=descending
 318+* (bug 14018) Introduced alcontinue to list=alllinks to improve paging
318319
319320 === Languages updated in 1.13 ===
320321

Status & tagging log