From 569b833ad2196c333a6f07713b56ecd612318bfe Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sat, 15 Jan 2011 00:00:25 +0000 Subject: [PATCH] More for bug 24650. Update continue to be usable unique thing --- includes/api/ApiQueryCategoryMembers.php | 35 ++++-------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/includes/api/ApiQueryCategoryMembers.php b/includes/api/ApiQueryCategoryMembers.php index 840258efcc..98c285e4b9 100644 --- a/includes/api/ApiQueryCategoryMembers.php +++ b/includes/api/ApiQueryCategoryMembers.php @@ -135,7 +135,7 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { $this->addOption( 'LIMIT', $limit + 1 ); $count = 0; - $lastSortKey = null; + $lastFrom = null; $res = $this->select( __METHOD__ ); foreach ( $res as $row ) { if ( ++ $count > $limit ) { @@ -144,7 +144,7 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { if ( $params['sort'] == 'timestamp' ) { $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) ); } else { - $this->setContinueEnumParameter( 'continue', $this->getContinueStr( $row, $lastSortKey ) ); + $this->setContinueEnumParameter( 'continue', $lastFrom ); } break; } @@ -181,14 +181,14 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { if ( $params['sort'] == 'timestamp' ) { $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) ); } else { - $this->setContinueEnumParameter( 'continue', $this->getContinueStr( $row, $lastSortKey ) ); + $this->setContinueEnumParameter( 'continue', $lastFrom ); } break; } } else { $resultPageSet->processDbRow( $row ); } - $lastSortKey = $row->cl_sortkey; // detect duplicate sortkeys + $lastFrom = $row->cl_from; // detect duplicate sortkeys } if ( is_null( $resultPageSet ) ) { @@ -197,14 +197,6 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { } } - private function getContinueStr( $row, $lastSortKey ) { - $ret = $row->cl_sortkey . '|'; - if ( $row->cl_sortkey == $lastSortKey ) { // duplicate sort key, add cl_from - $ret .= $row->cl_from; - } - return $ret; - } - /** * Add DB WHERE clause to continue previous query based on 'continue' parameter */ @@ -213,26 +205,11 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { return; // This is not a continuation request } - $pos = strrpos( $continue, '|' ); - $sortkey = substr( $continue, 0, $pos ); - $fromstr = substr( $continue, $pos + 1 ); - $from = intval( $fromstr ); - - if ( $from == 0 && strlen( $fromstr ) > 0 ) { - $this->dieUsage( 'Invalid continue param. You should pass the original value returned by the previous query', 'badcontinue' ); - } - - $encSortKey = $this->getDB()->addQuotes( $sortkey ); - $encFrom = $this->getDB()->addQuotes( $from ); + $encFrom = $this->getDB()->addQuotes( intval( $continue ) ); $op = ( $dir == 'desc' ? '<' : '>' ); - if ( $from != 0 ) { - // Duplicate sort key continue - $this->addWhere( "cl_sortkey$op$encSortKey OR (cl_sortkey=$encSortKey AND cl_from$op=$encFrom)" ); - } else { - $this->addWhere( "cl_sortkey$op=$encSortKey" ); - } + $this->addWhere( "cl_from $op $encFrom" ); } public function getAllowedParams() { -- 2.20.1