X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryWatchlist.php;h=869faea7a4b509b08348de29fce17329f451b8da;hb=45a51d8506bbbf738f9610355c40cf1ea17cd7d6;hp=b7dc86543c79571c65ba692aa9a8d4e89a013371;hpb=5bd46a50a96b4eea0ead68aa0e7c5bf0d17f4910;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php index b7dc86543c..869faea7a4 100644 --- a/includes/api/ApiQueryWatchlist.php +++ b/includes/api/ApiQueryWatchlist.php @@ -51,7 +51,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { $fld_loginfo = false; /** - * @param $resultPageSet ApiPageSet + * @param ApiPageSet $resultPageSet * @return void */ private function run( $resultPageSet = null ) { @@ -86,6 +86,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { } $this->addFields( array( + 'rc_id', 'rc_namespace', 'rc_title', 'rc_timestamp', @@ -135,6 +136,22 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { $this->addTimestampWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] ); + // Include in ORDER BY for uniqueness + $this->addWhereRange( 'rc_id', $params['dir'], null, null ); + + if ( !is_null( $params['continue'] ) ) { + $cont = explode( '|', $params['continue'] ); + $this->dieContinueUsageIf( count( $cont ) != 2 ); + $op = ( $params['dir'] === 'newer' ? '>' : '<' ); + $continueTimestamp = $db->addQuotes( $db->timestamp( $cont[0] ) ); + $continueId = (int)$cont[1]; + $this->dieContinueUsageIf( $continueId != $cont[1] ); + $this->addWhere( "rc_timestamp $op $continueTimestamp OR " . + "(rc_timestamp = $continueTimestamp AND " . + "rc_id $op= $continueId)" + ); + } + $this->addWhereFld( 'wl_namespace', $params['namespace'] ); if ( !$params['allrev'] ) { @@ -236,10 +253,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { if ( ++$count > $params['limit'] ) { // We've reached the one extra which shows that there are // additional pages to be had. Stop here... - $this->setContinueEnumParameter( - 'start', - wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) - ); + $this->setContinueEnumParameter( 'continue', "$row->rc_timestamp|$row->rc_id" ); break; } @@ -247,8 +261,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { $vals = $this->extractRowInfo( $row ); $fit = $this->getResult()->addValue( array( 'query', $this->getModuleName() ), null, $vals ); if ( !$fit ) { - $this->setContinueEnumParameter( 'start', - wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) ); + $this->setContinueEnumParameter( 'continue', "$row->rc_timestamp|$row->rc_id" ); break; } } else { @@ -544,6 +557,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { 'token' => array( ApiBase::PARAM_TYPE => 'string' ), + 'continue' => null, ); } @@ -588,6 +602,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { 'owner' => 'The name of the user whose watchlist you\'d like to access', 'token' => 'Give a security token (settable in preferences) to ' . 'allow access to another user\'s watchlist', + 'continue' => 'When more results are available, use this to continue', ); } @@ -674,7 +689,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { } public function getDescription() { - return "Get all recent changes to pages in the logged in user's watchlist"; + return "Get all recent changes to pages in the logged in user's watchlist."; } public function getPossibleErrors() {