Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php |
— | — | @@ -74,13 +74,22 @@ |
75 | 75 | |
76 | 76 | $this->addFieldsIf('cl_timestamp', $fld_timestamp); |
77 | 77 | $this->addTables(array('page','categorylinks')); // must be in this order for 'USE INDEX' |
78 | | - $this->addOption('USE INDEX', 'cl_sortkey'); // Not needed after bug 10280 is applied to servers |
| 78 | + // Not needed after bug 10280 is applied to servers |
| 79 | + if($params['sort'] == 'timestamp') |
| 80 | + { |
| 81 | + $this->addOption('USE INDEX', 'cl_timestamp'); |
| 82 | + $this->addOption('ORDER BY', 'cl_to, cl_timestamp'); |
| 83 | + } |
| 84 | + else |
| 85 | + { |
| 86 | + $this->addOption('USE INDEX', 'cl_sortkey'); |
| 87 | + $this->addOption('ORDER BY', 'cl_to, cl_sortkey, cl_from'); |
| 88 | + } |
79 | 89 | |
80 | 90 | $this->addWhere('cl_from=page_id'); |
81 | 91 | $this->setContinuation($params['continue']); |
82 | 92 | $this->addWhereFld('cl_to', $categoryTitle->getDBkey()); |
83 | 93 | $this->addWhereFld('page_namespace', $params['namespace']); |
84 | | - $this->addOption('ORDER BY', "cl_to, cl_sortkey, cl_from"); |
85 | 94 | |
86 | 95 | $limit = $params['limit']; |
87 | 96 | $this->addOption('LIMIT', $limit +1); |
— | — | @@ -188,6 +197,13 @@ |
189 | 198 | ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1, |
190 | 199 | ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2 |
191 | 200 | ), |
| 201 | + 'sort' => array( |
| 202 | + ApiBase :: PARAM_DFLT => 'sortkey', |
| 203 | + ApiBase :: PARAM_TYPE => array( |
| 204 | + 'sortkey', |
| 205 | + 'timestamp' |
| 206 | + ) |
| 207 | + ) |
192 | 208 | ); |
193 | 209 | } |
194 | 210 | |
— | — | @@ -196,6 +212,7 @@ |
197 | 213 | 'category' => 'Which category to enumerate (required)', |
198 | 214 | 'prop' => 'What pieces of information to include', |
199 | 215 | 'namespace' => 'Only include pages in these namespaces', |
| 216 | + 'sort' => 'Property to sort by', |
200 | 217 | 'continue' => 'For large categories, give the value retured from previous query', |
201 | 218 | 'limit' => 'The maximum number of pages to return.', |
202 | 219 | ); |