Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php |
— | — | @@ -119,13 +119,12 @@ |
120 | 120 | |
121 | 121 | $this->addOption( 'USE INDEX', 'cl_timestamp' ); |
122 | 122 | } else { |
123 | | - $this->addOption( 'ORDER BY', 'cl_type' ); |
124 | | - |
| 123 | + // The below produces ORDER BY cl_type, cl_sortkey, cl_from, possibly with DESC added to each of them |
| 124 | + $this->addWhereRange( 'cl_type', $dir, null, null ); |
125 | 125 | $this->addWhereRange( 'cl_sortkey', |
126 | 126 | $dir, |
127 | 127 | $params['startsortkey'], |
128 | 128 | $params['endsortkey'] ); |
129 | | - |
130 | 129 | $this->addWhereRange( 'cl_from', $dir, null, null ); |
131 | 130 | $this->addOption( 'USE INDEX', 'cl_sortkey' ); |
132 | 131 | } |
— | — | @@ -138,7 +137,6 @@ |
139 | 138 | $this->addOption( 'LIMIT', $limit + 1 ); |
140 | 139 | |
141 | 140 | $count = 0; |
142 | | - $lastFrom = null; |
143 | 141 | $res = $this->select( __METHOD__ ); |
144 | 142 | foreach ( $res as $row ) { |
145 | 143 | if ( ++ $count > $limit ) { |
— | — | @@ -147,7 +145,7 @@ |
148 | 146 | if ( $params['sort'] == 'timestamp' ) { |
149 | 147 | $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) ); |
150 | 148 | } else { |
151 | | - $this->setContinueEnumParameter( 'continue', $lastFrom ); |
| 149 | + $this->setContinueEnumParameter( 'continue', $row->cl_from ); |
152 | 150 | } |
153 | 151 | break; |
154 | 152 | } |
— | — | @@ -187,14 +185,13 @@ |
188 | 186 | if ( $params['sort'] == 'timestamp' ) { |
189 | 187 | $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) ); |
190 | 188 | } else { |
191 | | - $this->setContinueEnumParameter( 'continue', $lastFrom ); |
| 189 | + $this->setContinueEnumParameter( 'continue', $row->cl_from ); |
192 | 190 | } |
193 | 191 | break; |
194 | 192 | } |
195 | 193 | } else { |
196 | 194 | $resultPageSet->processDbRow( $row ); |
197 | 195 | } |
198 | | - $lastFrom = $row->cl_from; // detect duplicate sortkeys |
199 | 196 | } |
200 | 197 | |
201 | 198 | if ( is_null( $resultPageSet ) ) { |
— | — | @@ -213,7 +210,7 @@ |
214 | 211 | |
215 | 212 | $encFrom = $this->getDB()->addQuotes( intval( $continue ) ); |
216 | 213 | |
217 | | - $op = ( $dir == 'desc' ? '<' : '>' ); |
| 214 | + $op = ( $dir == 'desc' ? '<=' : '>=' ); |
218 | 215 | |
219 | 216 | $this->addWhere( "cl_from $op $encFrom" ); |
220 | 217 | } |
— | — | @@ -294,9 +291,9 @@ |
295 | 292 | 'What pieces of information to include', |
296 | 293 | ' ids - Adds the page ID', |
297 | 294 | ' title - Adds the title and namespace ID of the page', |
298 | | - ' sortkey - Adds the sortkey used for the category (note, may be non human readable)', |
299 | | - ' sortkeyprefix - Adds the sortkey prefix used for the category', |
300 | | - ' type - Adds the type that the page has been categorised as', |
| 295 | + ' sortkey - Adds the sortkey used for sorting in the category (may not be human-readble)', |
| 296 | + ' sortkeyprefix - Adds the sortkey prefix used for sorting in the category (human-readable part of the sortkey)', |
| 297 | + ' type - Adds the type that the page has been categorised as (page, subcat or file)', |
301 | 298 | ' timestamp - Adds the timestamp of when the page was included', |
302 | 299 | ), |
303 | 300 | 'namespace' => 'Only include pages in these namespaces', |