r84908 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84907‎ | r84908 | r84909 >
Date:16:52, 28 March 2011
Author:catrope
Status:ok
Tags:
Comment:
1.17wmf1: MFT r84905
Modified paths:
  • /branches/wmf/1.17wmf1/includes/api/ApiQueryCategoryMembers.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/includes/api/ApiQueryCategoryMembers.php
@@ -144,26 +144,34 @@
145145 $limit = $params['limit'];
146146 $this->addOption( 'LIMIT', $limit + 1 );
147147
148 - // Run a separate SELECT query for each value of cl_type.
149 - // This is needed because cl_type is an enum, and MySQL has
150 - // inconsistencies between ORDER BY cl_type and
151 - // WHERE cl_type >= 'foo' making proper paging impossible
152 - // and unindexed.
153 - $rows = array();
154 - $first = true;
155 - foreach ( $queryTypes as $type ) {
156 - $extraConds = array( 'cl_type' => $type );
157 - if ( $first && $contWhere ) {
158 - // Continuation condition. Only added to the
159 - // first query, otherwise we'll skip things
160 - $extraConds[] = $contWhere;
 148+ if ( $params['sort'] == 'sortkey' ) {
 149+ // Run a separate SELECT query for each value of cl_type.
 150+ // This is needed because cl_type is an enum, and MySQL has
 151+ // inconsistencies between ORDER BY cl_type and
 152+ // WHERE cl_type >= 'foo' making proper paging impossible
 153+ // and unindexed.
 154+ $rows = array();
 155+ $first = true;
 156+ foreach ( $queryTypes as $type ) {
 157+ $extraConds = array( 'cl_type' => $type );
 158+ if ( $first && $contWhere ) {
 159+ // Continuation condition. Only added to the
 160+ // first query, otherwise we'll skip things
 161+ $extraConds[] = $contWhere;
 162+ }
 163+ $res = $this->select( __METHOD__, array( 'where' => $extraConds ) );
 164+ $rows = array_merge( $rows, iterator_to_array( $res ) );
 165+ if ( count( $rows ) >= $limit + 1 ) {
 166+ break;
 167+ }
 168+ $first = false;
161169 }
162 - $res = $this->select( __METHOD__, array( 'where' => $extraConds ) );
163 - $rows = array_merge( $rows, iterator_to_array( $res ) );
164 - if ( count( $rows ) >= $limit + 1 ) {
165 - break;
166 - }
167 - $first = false;
 170+ } else {
 171+ // Sorting by timestamp
 172+ // No need to worry about per-type queries because we
 173+ // aren't sorting or filtering by type anyway
 174+ $res = $this->select( __METHOD__ );
 175+ $rows = iterator_to_array( $res );
168176 }
169177 $count = 0;
170178 foreach ( $rows as $row ) {
@@ -315,7 +323,7 @@
316324 ' timestamp - Adds the timestamp of when the page was included',
317325 ),
318326 'namespace' => 'Only include pages in these namespaces',
319 - 'type' => 'What type of category members to include',
 327+ 'type' => "What type of category members to include. Ignored when {$p}sort=timestamp is set",
320328 'sort' => 'Property to sort by',
321329 'dir' => 'In which direction to sort',
322330 'start' => "Timestamp to start listing from. Can only be used with {$p}sort=timestamp",
Property changes on: branches/wmf/1.17wmf1/includes/api/ApiQueryCategoryMembers.php
___________________________________________________________________
Added: svn:mergeinfo
323331 Merged /branches/sqlite/includes/api/ApiQueryCategoryMembers.php:r58211-58321
324332 Merged /trunk/phase3/includes/api/ApiQueryCategoryMembers.php:r84905
325333 Merged /branches/wmf-deployment/includes/api/ApiQueryCategoryMembers.php:r53381,59952,60970
326334 Merged /branches/REL1_15/phase3/includes/api/ApiQueryCategoryMembers.php:r51646
327335 Merged /branches/REL1_16/phase3/includes/api/ApiQueryCategoryMembers.php:r63621-63636,69357
328336 Merged /branches/wmf/1.16wmf4/includes/api/ApiQueryCategoryMembers.php:r67177,69199,69521,76243,77266

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84905BREAKING CHANGE: Ignore cmtype when cmsort=timestamp is set, and bypass the p...catrope15:01, 28 March 2011

Status & tagging log