Index: includes/api/ApiQueryRecentChanges.php =================================================================== --- includes/api/ApiQueryRecentChanges.php (revision 89526) +++ includes/api/ApiQueryRecentChanges.php (working copy) @@ -141,6 +141,24 @@ $this->addTables( 'recentchanges' ); $index = array( 'recentchanges' => 'rc_timestamp' ); // May change $this->addWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] ); + + if ( !is_null( $params['continue'] ) ) { + $cont = explode( '|', $params['continue'] ); + if ( count( $cont ) != 2 ) { + $this->dieUsage( 'Invalid continue param. You should pass the ' . + 'original value returned by the previous query', '_badcontinue' ); + } + + $timestamp = $this->getDB()->addQuotes( $cont[0] ); + $id = intval( $cont[1] ); + + $this->addWhere( + "rc_timestamp > $timestamp OR " . + "(rc_timestamp = $timestamp AND " . + "rc_id >= '$id')" + ); + } + $this->addWhereFld( 'rc_namespace', $params['namespace'] ); $this->addWhereFld( 'rc_deleted', 0 ); @@ -223,8 +241,9 @@ $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' ); } + $this->addFields( 'rc_id' ); /* Add fields to our query if they are specified as a needed parameter. */ - $this->addFieldsIf( array( 'rc_id', 'rc_this_oldid', 'rc_last_oldid' ), $this->fld_ids ); + $this->addFieldsIf( array( 'rc_this_oldid', 'rc_last_oldid' ), $this->fld_ids ); $this->addFieldsIf( 'rc_comment', $this->fld_comment || $this->fld_parsedcomment ); $this->addFieldsIf( 'rc_user', $this->fld_user ); $this->addFieldsIf( 'rc_user_text', $this->fld_user || $this->fld_userid ); @@ -273,7 +292,7 @@ foreach ( $res as $row ) { 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', wfTimestamp( TS_ISO_8601, "{$row->rc_timestamp}|{$row->rc_id}" ) ); break; } @@ -287,7 +306,7 @@ } $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', wfTimestamp( TS_ISO_8601, "{$row->rc_timestamp}|{$row->rc_id}" ) ); break; } } else { @@ -579,6 +598,7 @@ ) ), 'toponly' => false, + 'continue' => null, ); } @@ -616,6 +636,7 @@ 'limit' => 'How many total changes to return', 'tag' => 'Only list changes tagged with this tag', 'toponly' => 'Only list changes which are the latest revision', + 'continue' => 'When more results are available, use this to continue', ); }