Index: branches/REL1_14/phase3/includes/api/ApiQueryAllLinks.php |
— | — | @@ -74,9 +74,11 @@ |
75 | 75 | $arr = explode('|', $params['continue']); |
76 | 76 | if(count($arr) != 2) |
77 | 77 | $this->dieUsage("Invalid continue parameter", 'badcontinue'); |
78 | | - $params['from'] = $arr[0]; // Handled later |
| 78 | + $from = $this->getDB()->strencode($this->titleToKey($arr[0])); |
79 | 79 | $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)"); |
81 | 83 | } |
82 | 84 | |
83 | 85 | if (!is_null($params['from'])) |
— | — | @@ -85,19 +87,17 @@ |
86 | 88 | $this->addWhere("pl_title LIKE '" . $db->escapeLike($this->titlePartToKey($params['prefix'])) . "%'"); |
87 | 89 | |
88 | 90 | $this->addFields(array ( |
89 | | - 'pl_namespace', |
90 | 91 | 'pl_title', |
91 | | - 'pl_from' |
92 | 92 | )); |
| 93 | + $this->addFieldsIf('pl_from', !$params['unique']); |
93 | 94 | |
94 | 95 | $this->addOption('USE INDEX', 'pl_namespace'); |
95 | 96 | $limit = $params['limit']; |
96 | 97 | $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'); |
100 | 100 | else |
101 | | - $this->addOption('ORDER BY', 'pl_title'); |
| 101 | + $this->addOption('ORDER BY', 'pl_title, pl_from'); |
102 | 102 | |
103 | 103 | $res = $this->select(__METHOD__); |
104 | 104 | |
— | — | @@ -107,7 +107,10 @@ |
108 | 108 | if (++ $count > $limit) { |
109 | 109 | // We've reached the one extra which shows that there are additional pages to be had. Stop here... |
110 | 110 | // 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); |
112 | 115 | break; |
113 | 116 | } |
114 | 117 | |
— | — | @@ -116,7 +119,7 @@ |
117 | 120 | if ($fld_ids) |
118 | 121 | $vals['fromid'] = intval($row->pl_from); |
119 | 122 | if ($fld_title) { |
120 | | - $title = Title :: makeTitle($row->pl_namespace, $row->pl_title); |
| 123 | + $title = Title :: makeTitle($params['namespace'], $row->pl_title); |
121 | 124 | $vals['ns'] = intval($title->getNamespace()); |
122 | 125 | $vals['title'] = $title->getPrefixedText(); |
123 | 126 | } |