Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php |
— | — | @@ -160,26 +160,34 @@ |
161 | 161 | $limit = $params['limit']; |
162 | 162 | $this->addOption( 'LIMIT', $limit + 1 ); |
163 | 163 | |
164 | | - // Run a separate SELECT query for each value of cl_type. |
165 | | - // This is needed because cl_type is an enum, and MySQL has |
166 | | - // inconsistencies between ORDER BY cl_type and |
167 | | - // WHERE cl_type >= 'foo' making proper paging impossible |
168 | | - // and unindexed. |
169 | | - $rows = array(); |
170 | | - $first = true; |
171 | | - foreach ( $queryTypes as $type ) { |
172 | | - $extraConds = array( 'cl_type' => $type ); |
173 | | - if ( $first && $contWhere ) { |
174 | | - // Continuation condition. Only added to the |
175 | | - // first query, otherwise we'll skip things |
176 | | - $extraConds[] = $contWhere; |
| 164 | + if ( $params['sort'] == 'sortkey' ) { |
| 165 | + // Run a separate SELECT query for each value of cl_type. |
| 166 | + // This is needed because cl_type is an enum, and MySQL has |
| 167 | + // inconsistencies between ORDER BY cl_type and |
| 168 | + // WHERE cl_type >= 'foo' making proper paging impossible |
| 169 | + // and unindexed. |
| 170 | + $rows = array(); |
| 171 | + $first = true; |
| 172 | + foreach ( $queryTypes as $type ) { |
| 173 | + $extraConds = array( 'cl_type' => $type ); |
| 174 | + if ( $first && $contWhere ) { |
| 175 | + // Continuation condition. Only added to the |
| 176 | + // first query, otherwise we'll skip things |
| 177 | + $extraConds[] = $contWhere; |
| 178 | + } |
| 179 | + $res = $this->select( __METHOD__, array( 'where' => $extraConds ) ); |
| 180 | + $rows = array_merge( $rows, iterator_to_array( $res ) ); |
| 181 | + if ( count( $rows ) >= $limit + 1 ) { |
| 182 | + break; |
| 183 | + } |
| 184 | + $first = false; |
177 | 185 | } |
178 | | - $res = $this->select( __METHOD__, array( 'where' => $extraConds ) ); |
179 | | - $rows = array_merge( $rows, iterator_to_array( $res ) ); |
180 | | - if ( count( $rows ) >= $limit + 1 ) { |
181 | | - break; |
182 | | - } |
183 | | - $first = false; |
| 186 | + } else { |
| 187 | + // Sorting by timestamp |
| 188 | + // No need to worry about per-type queries because we |
| 189 | + // aren't sorting or filtering by type anyway |
| 190 | + $res = $this->select( __METHOD__ ); |
| 191 | + $rows = iterator_to_array( $res ); |
184 | 192 | } |
185 | 193 | $count = 0; |
186 | 194 | foreach ( $rows as $row ) { |
— | — | @@ -334,7 +342,7 @@ |
335 | 343 | ' timestamp - Adds the timestamp of when the page was included', |
336 | 344 | ), |
337 | 345 | 'namespace' => 'Only include pages in these namespaces', |
338 | | - 'type' => 'What type of category members to include', |
| 346 | + 'type' => "What type of category members to include. Ignored when {$p}sort=timestamp is set", |
339 | 347 | 'sort' => 'Property to sort by', |
340 | 348 | 'dir' => 'In which direction to sort', |
341 | 349 | 'start' => "Timestamp to start listing from. Can only be used with {$p}sort=timestamp", |