r80358 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80357‎ | r80358 | r80359 >
Date:00:00, 15 January 2011
Author:reedy
Status:resolved
Tags:
Comment:
More for bug 24650. Update continue to be usable unique thing
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryCategoryMembers.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php
@@ -135,7 +135,7 @@
136136 $this->addOption( 'LIMIT', $limit + 1 );
137137
138138 $count = 0;
139 - $lastSortKey = null;
 139+ $lastFrom = null;
140140 $res = $this->select( __METHOD__ );
141141 foreach ( $res as $row ) {
142142 if ( ++ $count > $limit ) {
@@ -144,7 +144,7 @@
145145 if ( $params['sort'] == 'timestamp' ) {
146146 $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) );
147147 } else {
148 - $this->setContinueEnumParameter( 'continue', $this->getContinueStr( $row, $lastSortKey ) );
 148+ $this->setContinueEnumParameter( 'continue', $lastFrom );
149149 }
150150 break;
151151 }
@@ -181,14 +181,14 @@
182182 if ( $params['sort'] == 'timestamp' ) {
183183 $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) );
184184 } else {
185 - $this->setContinueEnumParameter( 'continue', $this->getContinueStr( $row, $lastSortKey ) );
 185+ $this->setContinueEnumParameter( 'continue', $lastFrom );
186186 }
187187 break;
188188 }
189189 } else {
190190 $resultPageSet->processDbRow( $row );
191191 }
192 - $lastSortKey = $row->cl_sortkey; // detect duplicate sortkeys
 192+ $lastFrom = $row->cl_from; // detect duplicate sortkeys
193193 }
194194
195195 if ( is_null( $resultPageSet ) ) {
@@ -197,14 +197,6 @@
198198 }
199199 }
200200
201 - private function getContinueStr( $row, $lastSortKey ) {
202 - $ret = $row->cl_sortkey . '|';
203 - if ( $row->cl_sortkey == $lastSortKey ) { // duplicate sort key, add cl_from
204 - $ret .= $row->cl_from;
205 - }
206 - return $ret;
207 - }
208 -
209201 /**
210202 * Add DB WHERE clause to continue previous query based on 'continue' parameter
211203 */
@@ -213,26 +205,11 @@
214206 return; // This is not a continuation request
215207 }
216208
217 - $pos = strrpos( $continue, '|' );
218 - $sortkey = substr( $continue, 0, $pos );
219 - $fromstr = substr( $continue, $pos + 1 );
220 - $from = intval( $fromstr );
 209+ $encFrom = $this->getDB()->addQuotes( intval( $continue ) );
221210
222 - if ( $from == 0 && strlen( $fromstr ) > 0 ) {
223 - $this->dieUsage( 'Invalid continue param. You should pass the original value returned by the previous query', 'badcontinue' );
224 - }
225 -
226 - $encSortKey = $this->getDB()->addQuotes( $sortkey );
227 - $encFrom = $this->getDB()->addQuotes( $from );
228 -
229211 $op = ( $dir == 'desc' ? '<' : '>' );
230212
231 - if ( $from != 0 ) {
232 - // Duplicate sort key continue
233 - $this->addWhere( "cl_sortkey$op$encSortKey OR (cl_sortkey=$encSortKey AND cl_from$op=$encFrom)" );
234 - } else {
235 - $this->addWhere( "cl_sortkey$op=$encSortKey" );
236 - }
 213+ $this->addWhere( "cl_from $op $encFrom" );
237214 }
238215
239216 public function getAllowedParams() {

Follow-up revisions

RevisionCommit summaryAuthorDate
r80362Last bits of bug 24650 Fix API to work with categorylinks changes...reedy00:10, 15 January 2011
r80363* (bug 24650) Fix API to work with categorylinks changes...reedy00:13, 15 January 2011
r80540Various fixes for API category changes:...catrope00:13, 19 January 2011
r807221.17: MFT r80324, r80326, r80328, r80339, r80350, r80351, r80355, r80358, r80...catrope23:00, 21 January 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r80324Start of bug 24650 Fix API to work with categorylinks changes...reedy21:08, 14 January 2011

Status & tagging log