From: Roan Kattouw Date: Wed, 7 May 2008 19:15:06 +0000 (+0000) Subject: (bug 14018) Added alcontinue parameter to list=alllinks to improve paging; used to... X-Git-Tag: 1.31.0-rc.0~47839 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=302aa4bde6f31f50a36b64f4bb2c66256760360b;p=lhc%2Fweb%2Fwiklou.git (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 --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 7c8bd89999..95e75c53db 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -314,6 +314,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 13945) Retrieve cascading protection sources via inprop=protection * (bug 13965) Hardcoded 51 limit on titles is too limiting * (bug 13993) apfrom doesn't work with apdir=descending +* (bug 14018) Introduced alcontinue to list=alllinks to improve paging === Languages updated in 1.13 === diff --git a/includes/api/ApiQueryAllLinks.php b/includes/api/ApiQueryAllLinks.php index 9320af6bdf..d01112901a 100644 --- a/includes/api/ApiQueryAllLinks.php +++ b/includes/api/ApiQueryAllLinks.php @@ -66,6 +66,18 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { $this->addTables('pagelinks'); $this->addWhereFld('pl_namespace', $params['namespace']); + + if (!is_null($params['from']) && !is_null($params['continue'])) + $this->dieUsage('alcontinue and alfrom cannot be used together', 'params'); + if (!is_null($params['continue'])) + { + $arr = explode('|', $params['continue']); + if(count($arr) != 2) + $this->dieUsage("Invalid continue parameter", 'badcontinue'); + $params['from'] = $arr[0]; // Handled later + $id = intval($arr[1]); + $this->addWhere("pl_from >= $id"); + } if (!is_null($params['from'])) $this->addWhere('pl_title>=' . $db->addQuotes(ApiQueryBase :: titleToKey($params['from']))); @@ -75,9 +87,9 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { if (is_null($resultPageSet)) { $this->addFields(array ( 'pl_namespace', - 'pl_title' + 'pl_title', + 'pl_from' )); - $this->addFieldsIf('pl_from', $fld_ids); } else { $this->addFields('pl_from'); $pageids = array(); @@ -86,7 +98,7 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { $this->addOption('USE INDEX', 'pl_namespace'); $limit = $params['limit']; $this->addOption('LIMIT', $limit+1); - $this->addOption('ORDER BY', 'pl_namespace, pl_title'); + $this->addOption('ORDER BY', 'pl_title'); $res = $this->select(__METHOD__); @@ -96,7 +108,7 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { if (++ $count > $limit) { // We've reached the one extra which shows that there are additional pages to be had. Stop here... // TODO: Security issue - if the user has no right to view next title, it will still be shown - $this->setContinueEnumParameter('from', ApiQueryBase :: keyToTitle($row->pl_title)); + $this->setContinueEnumParameter('continue', ApiQueryBase :: keyToTitle($row->pl_title) . "|" . $row->pl_from); break; } @@ -127,6 +139,7 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { public function getAllowedParams() { return array ( + 'continue' => null, 'from' => null, 'prefix' => null, 'unique' => false,