r45850 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45849‎ | r45850 | r45851 >
Date:20:03, 17 January 2009
Author:catrope
Status:deferred
Tags:
Comment:
Backport r45849 (fix alllinks paging and make alunique actually work)
Modified paths:
  • /branches/REL1_14/phase3/includes/api/ApiQueryAllLinks.php (modified) (history)

Diff [purge]

Index: branches/REL1_14/phase3/includes/api/ApiQueryAllLinks.php
@@ -74,9 +74,11 @@
7575 $arr = explode('|', $params['continue']);
7676 if(count($arr) != 2)
7777 $this->dieUsage("Invalid continue parameter", 'badcontinue');
78 - $params['from'] = $arr[0]; // Handled later
 78+ $from = $this->getDB()->strencode($this->titleToKey($arr[0]));
7979 $id = intval($arr[1]);
80 - $this->addWhere("pl_from >= $id");
 80+ $this->addWhere("pl_title > '$from' OR " .
 81+ "(pl_title = '$from' AND " .
 82+ "pl_from > $id)");
8183 }
8284
8385 if (!is_null($params['from']))
@@ -85,19 +87,17 @@
8688 $this->addWhere("pl_title LIKE '" . $db->escapeLike($this->titlePartToKey($params['prefix'])) . "%'");
8789
8890 $this->addFields(array (
89 - 'pl_namespace',
9091 'pl_title',
91 - 'pl_from'
9292 ));
 93+ $this->addFieldsIf('pl_from', !$params['unique']);
9394
9495 $this->addOption('USE INDEX', 'pl_namespace');
9596 $limit = $params['limit'];
9697 $this->addOption('LIMIT', $limit+1);
97 - # Only order by pl_namespace if it isn't constant in the WHERE clause
98 - if(count($params['namespace']) != 1)
99 - $this->addOption('ORDER BY', 'pl_namespace, pl_title');
 98+ if($params['unique'])
 99+ $this->addOption('ORDER BY', 'pl_title');
100100 else
101 - $this->addOption('ORDER BY', 'pl_title');
 101+ $this->addOption('ORDER BY', 'pl_title, pl_from');
102102
103103 $res = $this->select(__METHOD__);
104104
@@ -107,7 +107,10 @@
108108 if (++ $count > $limit) {
109109 // We've reached the one extra which shows that there are additional pages to be had. Stop here...
110110 // TODO: Security issue - if the user has no right to view next title, it will still be shown
111 - $this->setContinueEnumParameter('continue', $this->keyToTitle($row->pl_title) . "|" . $row->pl_from);
 111+ if($params['unique'])
 112+ $this->setContinueEnumParameter('from', $this->keyToTitle($row->pl_title));
 113+ else
 114+ $this->setContinueEnumParameter('continue', $this->keyToTitle($row->pl_title) . "|" . $row->pl_from);
112115 break;
113116 }
114117
@@ -116,7 +119,7 @@
117120 if ($fld_ids)
118121 $vals['fromid'] = intval($row->pl_from);
119122 if ($fld_title) {
120 - $title = Title :: makeTitle($row->pl_namespace, $row->pl_title);
 123+ $title = Title :: makeTitle($params['namespace'], $row->pl_title);
121124 $vals['ns'] = intval($title->getNamespace());
122125 $vals['title'] = $title->getPrefixedText();
123126 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r45895Add RELEASE-NOTES entry for r45849 (backported in r45850)catrope14:19, 19 January 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r45849API: Fixing paging in list=alllinks, which seems to have been broken for a lo...catrope19:52, 17 January 2009

Status & tagging log