* @file
*/
+use MediaWiki\MediaWikiServices;
+use MediaWiki\Storage\NameTableAccessException;
+
/**
* Query action to List the log events, with optional filtering by various parameters.
*
$fld_details = false, $fld_tags = false;
public function execute() {
+ global $wgChangeTagsSchemaMigrationStage;
+
$params = $this->extractRequestParams();
$db = $this->getDB();
$this->commentStore = CommentStore::getStore();
$this->addTables( 'change_tag' );
$this->addJoinConds( [ 'change_tag' => [ 'INNER JOIN',
[ 'log_id=ct_log_id' ] ] ] );
- $this->addWhereFld( 'ct_tag', $params['tag'] );
+ if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
+ $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
+ try {
+ $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
+ } catch ( NameTableAccessException $exception ) {
+ // Return nothing.
+ $this->addWhere( '1=0' );
+ }
+ } else {
+ $this->addWhereFld( 'ct_tag', $params['tag'] );
+ }
}
if ( !is_null( $params['action'] ) ) {
if ( !is_null( $user ) ) {
// Note the joins in $q are the same as those from ->getJoin() above
// so we only need to add 'conds' here.
- // Don't query by user ID here, it might be able to use the
- // log_user_text_time or log_user_text_type_time index.
$q = $actorMigration->getWhere(
- $db, 'log_user', User::newFromName( $params['user'], false ), false
+ $db, 'log_user', User::newFromName( $params['user'], false )
);
$this->addWhere( $q['conds'] );
}
$result->addIndexedTagName( [ 'query', $this->getModuleName() ], 'item' );
}
- /**
- * @deprecated since 1.25 Use LogFormatter::formatParametersForApi instead
- * @param ApiResult $result
- * @param array &$vals
- * @param string $params
- * @param string $type
- * @param string $action
- * @param string $ts
- * @param bool $legacy
- * @return array
- */
- public static function addLogParams( $result, &$vals, $params, $type,
- $action, $ts, $legacy = false
- ) {
- wfDeprecated( __METHOD__, '1.25' );
-
- $entry = new ManualLogEntry( $type, $action );
- $entry->setParameters( $params );
- $entry->setTimestamp( $ts );
- $entry->setLegacy( $legacy );
- $formatter = LogFormatter::newFromEntry( $entry );
- $vals['params'] = $formatter->formatParametersForApi();
-
- return $vals;
- }
-
private function extractRowInfo( $row ) {
$logEntry = DatabaseLogEntry::newFromRow( $row );
$vals = [
}
if ( LogEventsList::userCan( $row, LogPage::DELETED_USER, $user ) ) {
if ( $this->fld_user ) {
- $vals['user'] = $row->user_name === null ? $row->log_user_text : $row->user_name;
+ $vals['user'] = $row->user_name ?? $row->log_user_text;
}
if ( $this->fld_userid ) {
$vals['userid'] = intval( $row->log_user );
public function getAllowedParams( $flags = 0 ) {
$config = $this->getConfig();
+ if ( $flags & ApiBase::GET_VALUES_FOR_HELP ) {
+ $logActions = $this->getAllowedLogActions();
+ sort( $logActions );
+ } else {
+ $logActions = null;
+ }
$ret = [
'prop' => [
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
],
'type' => [
- ApiBase::PARAM_TYPE => $config->get( 'LogTypes' )
+ ApiBase::PARAM_TYPE => LogPage::validTypes(),
],
'action' => [
// validation on request is done in execute()
- ApiBase::PARAM_TYPE => ( $flags & ApiBase::GET_VALUES_FOR_HELP )
- ? $this->getAllowedLogActions()
- : null
+ ApiBase::PARAM_TYPE => $logActions
],
'start' => [
ApiBase::PARAM_TYPE => 'timestamp'