X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryLogEvents.php;h=ee7fbc006ff54abad406c057a8f9176f1f2f8e8d;hb=b101f0543823f5db81b850329573a678d0e0bd94;hp=b607ca543ec70b18d56da0845302bb99e4bd8b25;hpb=b42f229989084ea0b5c7dabea23a03c54460744c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php index b607ca543e..ee7fbc006f 100644 --- a/includes/api/ApiQueryLogEvents.php +++ b/includes/api/ApiQueryLogEvents.php @@ -73,13 +73,14 @@ class ApiQueryLogEvents extends ApiQueryBase { 'log_title=page_title' ) ) ) ); $this->addFields( array( + 'log_id', 'log_type', 'log_action', 'log_timestamp', 'log_deleted', ) ); - $this->addFieldsIf( array( 'log_id', 'page_id' ), $this->fld_ids ); + $this->addFieldsIf( 'page_id', $this->fld_ids ); $this->addFieldsIf( array( 'log_user', 'log_user_text', 'user_name' ), $this->fld_user ); $this->addFieldsIf( 'log_user', $this->fld_userid ); $this->addFieldsIf( @@ -135,6 +136,21 @@ class ApiQueryLogEvents extends ApiQueryBase { $params['start'], $params['end'] ); + // Include in ORDER BY for uniqueness + $this->addWhereRange( 'log_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( "log_timestamp $op $continueTimestamp OR " . + "(log_timestamp = $continueTimestamp AND " . + "log_id $op= $continueId)" + ); + } $limit = $params['limit']; $this->addOption( 'LIMIT', $limit + 1 ); @@ -202,7 +218,7 @@ class ApiQueryLogEvents extends ApiQueryBase { if ( ++$count > $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->log_timestamp ) ); + $this->setContinueEnumParameter( 'continue', "$row->log_timestamp|$row->log_id" ); break; } @@ -212,7 +228,7 @@ class ApiQueryLogEvents extends ApiQueryBase { } $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals ); if ( !$fit ) { - $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->log_timestamp ) ); + $this->setContinueEnumParameter( 'continue', "$row->log_timestamp|$row->log_id" ); break; } } @@ -497,7 +513,8 @@ class ApiQueryLogEvents extends ApiQueryBase { ApiBase::PARAM_MIN => 1, ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 - ) + ), + 'continue' => null, ); } @@ -531,6 +548,7 @@ class ApiQueryLogEvents extends ApiQueryBase { 'prefix' => 'Filter entries that start with this prefix. Disabled in Miser Mode', 'limit' => 'How many total event entries to return', 'tag' => 'Only list event entries tagged with this tag', + 'continue' => 'When more results are available, use this to continue', ); }