2006-11-01 12:07:20 +00:00
|
|
|
<?php
|
2010-02-26 13:18:56 +00:00
|
|
|
/**
|
2012-07-15 20:13:02 +00:00
|
|
|
* Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
|
2006-11-01 12:07:20 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
2010-06-21 13:13:32 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2006-11-01 12:07:20 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-08-07 19:59:42 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
2006-11-01 12:07:20 +00:00
|
|
|
*/
|
|
|
|
|
|
2007-04-20 08:55:14 +00:00
|
|
|
/**
|
2007-05-20 23:41:25 +00:00
|
|
|
* This query action adds a list of a specified user's contributions to the output.
|
2008-04-14 07:45:50 +00:00
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup API
|
2007-04-20 08:55:14 +00:00
|
|
|
*/
|
2018-05-25 00:46:30 +00:00
|
|
|
class ApiQueryUserContribs extends ApiQueryBase {
|
2006-11-01 12:07:20 +00:00
|
|
|
|
2014-03-25 17:22:11 +00:00
|
|
|
public function __construct( ApiQuery $query, $moduleName ) {
|
2010-02-26 13:18:56 +00:00
|
|
|
parent::__construct( $query, $moduleName, 'uc' );
|
2006-11-01 12:07:20 +00:00
|
|
|
}
|
|
|
|
|
|
2018-05-25 00:46:30 +00:00
|
|
|
private $params, $multiUserMode, $orderBy, $parentLens, $commentStore;
|
|
|
|
|
|
2007-05-21 04:34:48 +00:00
|
|
|
private $fld_ids = false, $fld_title = false, $fld_timestamp = false,
|
2013-11-14 13:00:02 +00:00
|
|
|
$fld_comment = false, $fld_parsedcomment = false, $fld_flags = false,
|
|
|
|
|
$fld_patrolled = false, $fld_tags = false, $fld_size = false, $fld_sizediff = false;
|
2007-05-15 03:35:32 +00:00
|
|
|
|
2007-05-20 23:41:25 +00:00
|
|
|
public function execute() {
|
2017-09-12 17:12:29 +00:00
|
|
|
global $wgActorTableSchemaMigrationStage;
|
|
|
|
|
|
2007-05-20 23:41:25 +00:00
|
|
|
// Parse some parameters
|
|
|
|
|
$this->params = $this->extractRequestParams();
|
2007-06-16 00:39:01 +00:00
|
|
|
|
2018-01-24 23:41:01 +00:00
|
|
|
$this->commentStore = CommentStore::getStore();
|
2017-06-06 17:39:14 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
$prop = array_flip( $this->params['prop'] );
|
|
|
|
|
$this->fld_ids = isset( $prop['ids'] );
|
|
|
|
|
$this->fld_title = isset( $prop['title'] );
|
|
|
|
|
$this->fld_comment = isset( $prop['comment'] );
|
2013-04-26 12:18:06 +00:00
|
|
|
$this->fld_parsedcomment = isset( $prop['parsedcomment'] );
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->fld_size = isset( $prop['size'] );
|
2012-06-16 07:47:11 +00:00
|
|
|
$this->fld_sizediff = isset( $prop['sizediff'] );
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->fld_flags = isset( $prop['flags'] );
|
|
|
|
|
$this->fld_timestamp = isset( $prop['timestamp'] );
|
|
|
|
|
$this->fld_patrolled = isset( $prop['patrolled'] );
|
|
|
|
|
$this->fld_tags = isset( $prop['tags'] );
|
2006-11-01 12:07:20 +00:00
|
|
|
|
2016-09-05 20:21:26 +00:00
|
|
|
// Most of this code will use the 'contributions' group DB, which can map to replica DBs
|
2014-03-02 18:07:06 +00:00
|
|
|
// with extra user based indexes or partioning by user. The additional metadata
|
2016-09-05 20:21:26 +00:00
|
|
|
// queries should use a regular replica DB since the lookup pattern is not all by user.
|
|
|
|
|
$dbSecondary = $this->getDB(); // any random replica DB
|
2014-03-02 18:07:06 +00:00
|
|
|
|
2007-05-20 23:41:25 +00:00
|
|
|
// TODO: if the query is going only against the revision table, should this be done?
|
2016-09-05 19:55:19 +00:00
|
|
|
$this->selectNamedDB( 'contributions', DB_REPLICA, 'contributions' );
|
2006-11-01 12:07:20 +00:00
|
|
|
|
2017-09-12 17:12:29 +00:00
|
|
|
$sort = ( $this->params['dir'] == 'newer' ? '' : ' DESC' );
|
|
|
|
|
$op = ( $this->params['dir'] == 'older' ? '<' : '>' );
|
2016-11-29 22:34:21 +00:00
|
|
|
|
2017-09-12 17:12:29 +00:00
|
|
|
// Create an Iterator that produces the UserIdentity objects we need, depending
|
|
|
|
|
// on which of the 'userprefix', 'userids', or 'user' params was
|
|
|
|
|
// specified.
|
|
|
|
|
$this->requireOnlyOneParameter( $this->params, 'userprefix', 'userids', 'user' );
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( isset( $this->params['userprefix'] ) ) {
|
2008-10-18 10:14:02 +00:00
|
|
|
$this->multiUserMode = true;
|
2017-09-12 17:12:29 +00:00
|
|
|
$this->orderBy = 'name';
|
|
|
|
|
$fname = __METHOD__;
|
|
|
|
|
|
|
|
|
|
// Because 'userprefix' might produce a huge number of users (e.g.
|
|
|
|
|
// a wiki with users "Test00000001" to "Test99999999"), use a
|
|
|
|
|
// generator with batched lookup and continuation.
|
|
|
|
|
$userIter = call_user_func( function () use ( $dbSecondary, $sort, $op, $fname ) {
|
|
|
|
|
global $wgActorTableSchemaMigrationStage;
|
|
|
|
|
|
2018-03-23 13:31:31 +00:00
|
|
|
$fromName = false;
|
2017-09-12 17:12:29 +00:00
|
|
|
if ( !is_null( $this->params['continue'] ) ) {
|
|
|
|
|
$continue = explode( '|', $this->params['continue'] );
|
|
|
|
|
$this->dieContinueUsageIf( count( $continue ) != 4 );
|
|
|
|
|
$this->dieContinueUsageIf( $continue[0] !== 'name' );
|
|
|
|
|
$fromName = $continue[1];
|
|
|
|
|
}
|
|
|
|
|
$like = $dbSecondary->buildLike( $this->params['userprefix'], $dbSecondary->anyString() );
|
|
|
|
|
|
|
|
|
|
$limit = 501;
|
|
|
|
|
|
|
|
|
|
do {
|
2018-03-23 13:31:31 +00:00
|
|
|
$from = $fromName ? "$op= " . $dbSecondary->addQuotes( $fromName ) : false;
|
|
|
|
|
|
2017-09-12 17:12:29 +00:00
|
|
|
// For the new schema, pull from the actor table. For the
|
|
|
|
|
// old, pull from rev_user. For migration a FULL [OUTER]
|
|
|
|
|
// JOIN would be what we want, except MySQL doesn't support
|
|
|
|
|
// that so we have to UNION instead.
|
|
|
|
|
if ( $wgActorTableSchemaMigrationStage === MIGRATION_NEW ) {
|
|
|
|
|
$res = $dbSecondary->select(
|
|
|
|
|
'actor',
|
|
|
|
|
[ 'actor_id', 'user_id' => 'COALESCE(actor_user,0)', 'user_name' => 'actor_name' ],
|
|
|
|
|
array_merge( [ "actor_name$like" ], $from ? [ "actor_name $from" ] : [] ),
|
|
|
|
|
$fname,
|
|
|
|
|
[ 'ORDER BY' => [ "user_name $sort" ], 'LIMIT' => $limit ]
|
|
|
|
|
);
|
|
|
|
|
} elseif ( $wgActorTableSchemaMigrationStage === MIGRATION_OLD ) {
|
|
|
|
|
$res = $dbSecondary->select(
|
|
|
|
|
'revision',
|
|
|
|
|
[ 'actor_id' => 'NULL', 'user_id' => 'rev_user', 'user_name' => 'rev_user_text' ],
|
|
|
|
|
array_merge( [ "rev_user_text$like" ], $from ? [ "rev_user_text $from" ] : [] ),
|
|
|
|
|
$fname,
|
|
|
|
|
[ 'DISTINCT', 'ORDER BY' => [ "rev_user_text $sort" ], 'LIMIT' => $limit ]
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
// There are three queries we have to combine to be sure of getting all results:
|
|
|
|
|
// - actor table (any rows that have been migrated will have empty rev_user_text)
|
|
|
|
|
// - revision+actor by user id
|
|
|
|
|
// - revision+actor by name for anons
|
|
|
|
|
$options = $dbSecondary->unionSupportsOrderAndLimit()
|
|
|
|
|
? [ 'ORDER BY' => [ "user_name $sort" ], 'LIMIT' => $limit ] : [];
|
|
|
|
|
$subsql = [];
|
|
|
|
|
$subsql[] = $dbSecondary->selectSQLText(
|
|
|
|
|
'actor',
|
|
|
|
|
[ 'actor_id', 'user_id' => 'COALESCE(actor_user,0)', 'user_name' => 'actor_name' ],
|
|
|
|
|
array_merge( [ "actor_name$like" ], $from ? [ "actor_name $from" ] : [] ),
|
|
|
|
|
$fname,
|
|
|
|
|
$options
|
|
|
|
|
);
|
|
|
|
|
$subsql[] = $dbSecondary->selectSQLText(
|
|
|
|
|
[ 'revision', 'actor' ],
|
|
|
|
|
[ 'actor_id', 'user_id' => 'rev_user', 'user_name' => 'rev_user_text' ],
|
|
|
|
|
array_merge(
|
|
|
|
|
[ "rev_user_text$like", 'rev_user != 0' ],
|
|
|
|
|
$from ? [ "rev_user_text $from" ] : []
|
|
|
|
|
),
|
|
|
|
|
$fname,
|
|
|
|
|
array_merge( [ 'DISTINCT' ], $options ),
|
|
|
|
|
[ 'actor' => [ 'LEFT JOIN', 'rev_user = actor_user' ] ]
|
|
|
|
|
);
|
|
|
|
|
$subsql[] = $dbSecondary->selectSQLText(
|
|
|
|
|
[ 'revision', 'actor' ],
|
|
|
|
|
[ 'actor_id', 'user_id' => 'rev_user', 'user_name' => 'rev_user_text' ],
|
|
|
|
|
array_merge(
|
|
|
|
|
[ "rev_user_text$like", 'rev_user = 0' ],
|
|
|
|
|
$from ? [ "rev_user_text $from" ] : []
|
|
|
|
|
),
|
|
|
|
|
$fname,
|
|
|
|
|
array_merge( [ 'DISTINCT' ], $options ),
|
|
|
|
|
[ 'actor' => [ 'LEFT JOIN', 'rev_user_text = actor_name' ] ]
|
|
|
|
|
);
|
|
|
|
|
$sql = $dbSecondary->unionQueries( $subsql, false ) . " ORDER BY user_name $sort";
|
|
|
|
|
$sql = $dbSecondary->limitResult( $sql, $limit );
|
|
|
|
|
$res = $dbSecondary->query( $sql, $fname );
|
|
|
|
|
}
|
2016-11-29 22:34:21 +00:00
|
|
|
|
2017-09-12 17:12:29 +00:00
|
|
|
$count = 0;
|
2018-03-23 13:31:31 +00:00
|
|
|
$fromName = false;
|
2017-09-12 17:12:29 +00:00
|
|
|
foreach ( $res as $row ) {
|
|
|
|
|
if ( ++$count >= $limit ) {
|
2018-03-23 13:31:31 +00:00
|
|
|
$fromName = $row->user_name;
|
2017-09-12 17:12:29 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
yield User::newFromRow( $row );
|
|
|
|
|
}
|
2018-03-23 13:31:31 +00:00
|
|
|
} while ( $fromName !== false );
|
2017-09-12 17:12:29 +00:00
|
|
|
} );
|
|
|
|
|
// Do the actual sorting client-side, because otherwise
|
|
|
|
|
// prepareQuery might try to sort by actor and confuse everything.
|
|
|
|
|
$batchSize = 1;
|
|
|
|
|
} elseif ( isset( $this->params['userids'] ) ) {
|
2016-11-29 22:34:21 +00:00
|
|
|
if ( !count( $this->params['userids'] ) ) {
|
|
|
|
|
$encParamName = $this->encodeParamName( 'userids' );
|
|
|
|
|
$this->dieWithError( [ 'apierror-paramempty', $encParamName ], "paramempty_$encParamName" );
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-12 17:12:29 +00:00
|
|
|
$ids = [];
|
2016-11-29 22:34:21 +00:00
|
|
|
foreach ( $this->params['userids'] as $uid ) {
|
|
|
|
|
if ( $uid <= 0 ) {
|
|
|
|
|
$this->dieWithError( [ 'apierror-invaliduserid', $uid ], 'invaliduserid' );
|
|
|
|
|
}
|
2017-09-12 17:12:29 +00:00
|
|
|
$ids[] = $uid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->orderBy = 'id';
|
|
|
|
|
$this->multiUserMode = count( $ids ) > 1;
|
2016-11-29 22:34:21 +00:00
|
|
|
|
2017-09-12 17:12:29 +00:00
|
|
|
$from = $fromId = false;
|
|
|
|
|
if ( $this->multiUserMode && !is_null( $this->params['continue'] ) ) {
|
|
|
|
|
$continue = explode( '|', $this->params['continue'] );
|
|
|
|
|
$this->dieContinueUsageIf( count( $continue ) != 4 );
|
|
|
|
|
$this->dieContinueUsageIf( $continue[0] !== 'id' && $continue[0] !== 'actor' );
|
|
|
|
|
$fromId = (int)$continue[1];
|
|
|
|
|
$this->dieContinueUsageIf( $continue[1] !== (string)$fromId );
|
|
|
|
|
$from = "$op= $fromId";
|
2016-11-29 22:34:21 +00:00
|
|
|
}
|
|
|
|
|
|
2017-09-12 17:12:29 +00:00
|
|
|
// For the new schema, just select from the actor table. For the
|
|
|
|
|
// old and transitional schemas, select from user and left join
|
|
|
|
|
// actor if it exists.
|
|
|
|
|
if ( $wgActorTableSchemaMigrationStage === MIGRATION_NEW ) {
|
|
|
|
|
$res = $dbSecondary->select(
|
|
|
|
|
'actor',
|
|
|
|
|
[ 'actor_id', 'user_id' => 'actor_user', 'user_name' => 'actor_name' ],
|
|
|
|
|
array_merge( [ 'actor_user' => $ids ], $from ? [ "actor_id $from" ] : [] ),
|
|
|
|
|
__METHOD__,
|
|
|
|
|
[ 'ORDER BY' => "user_id $sort" ]
|
|
|
|
|
);
|
|
|
|
|
} elseif ( $wgActorTableSchemaMigrationStage === MIGRATION_OLD ) {
|
|
|
|
|
$res = $dbSecondary->select(
|
|
|
|
|
'user',
|
|
|
|
|
[ 'actor_id' => 'NULL', 'user_id' => 'user_id', 'user_name' => 'user_name' ],
|
|
|
|
|
array_merge( [ 'user_id' => $ids ], $from ? [ "user_id $from" ] : [] ),
|
|
|
|
|
__METHOD__,
|
|
|
|
|
[ 'ORDER BY' => "user_id $sort" ]
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
$res = $dbSecondary->select(
|
|
|
|
|
[ 'user', 'actor' ],
|
|
|
|
|
[ 'actor_id', 'user_id', 'user_name' ],
|
|
|
|
|
array_merge( [ 'user_id' => $ids ], $from ? [ "user_id $from" ] : [] ),
|
|
|
|
|
__METHOD__,
|
|
|
|
|
[ 'ORDER BY' => "user_id $sort" ],
|
|
|
|
|
[ 'actor' => [ 'LEFT JOIN', 'actor_user = user_id' ] ]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
$userIter = UserArray::newFromResult( $res );
|
|
|
|
|
$batchSize = count( $ids );
|
2010-02-26 13:18:56 +00:00
|
|
|
} else {
|
2017-09-12 17:12:29 +00:00
|
|
|
$names = [];
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( !count( $this->params['user'] ) ) {
|
2016-10-19 16:54:25 +00:00
|
|
|
$encParamName = $this->encodeParamName( 'user' );
|
|
|
|
|
$this->dieWithError(
|
|
|
|
|
[ 'apierror-paramempty', $encParamName ], "paramempty_$encParamName"
|
|
|
|
|
);
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
|
|
|
|
foreach ( $this->params['user'] as $u ) {
|
2016-11-29 22:34:21 +00:00
|
|
|
if ( $u === '' ) {
|
2016-10-19 16:54:25 +00:00
|
|
|
$encParamName = $this->encodeParamName( 'user' );
|
|
|
|
|
$this->dieWithError(
|
|
|
|
|
[ 'apierror-paramempty', $encParamName ], "paramempty_$encParamName"
|
|
|
|
|
);
|
2016-03-28 20:20:24 +00:00
|
|
|
}
|
|
|
|
|
|
2018-02-12 15:11:40 +00:00
|
|
|
if ( User::isIP( $u ) || ExternalUserNames::isExternal( $u ) ) {
|
2017-09-12 17:12:29 +00:00
|
|
|
$names[$u] = null;
|
2016-03-28 20:20:24 +00:00
|
|
|
} else {
|
|
|
|
|
$name = User::getCanonicalName( $u, 'valid' );
|
|
|
|
|
if ( $name === false ) {
|
2016-10-19 16:54:25 +00:00
|
|
|
$encParamName = $this->encodeParamName( 'user' );
|
|
|
|
|
$this->dieWithError(
|
|
|
|
|
[ 'apierror-baduser', $encParamName, wfEscapeWikiText( $u ) ], "baduser_$encParamName"
|
|
|
|
|
);
|
2016-03-28 20:20:24 +00:00
|
|
|
}
|
2017-09-12 17:12:29 +00:00
|
|
|
$names[$name] = null;
|
2016-03-28 20:20:24 +00:00
|
|
|
}
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2016-03-28 20:20:24 +00:00
|
|
|
|
2017-09-12 17:12:29 +00:00
|
|
|
$this->orderBy = 'name';
|
|
|
|
|
$this->multiUserMode = count( $names ) > 1;
|
|
|
|
|
|
|
|
|
|
$from = $fromName = false;
|
|
|
|
|
if ( $this->multiUserMode && !is_null( $this->params['continue'] ) ) {
|
|
|
|
|
$continue = explode( '|', $this->params['continue'] );
|
|
|
|
|
$this->dieContinueUsageIf( count( $continue ) != 4 );
|
|
|
|
|
$this->dieContinueUsageIf( $continue[0] !== 'name' && $continue[0] !== 'actor' );
|
|
|
|
|
$fromName = $continue[1];
|
|
|
|
|
$from = "$op= " . $dbSecondary->addQuotes( $fromName );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// For the new schema, just select from the actor table. For the
|
|
|
|
|
// old and transitional schemas, select from user and left join
|
|
|
|
|
// actor if it exists then merge in any unknown users (IPs and imports).
|
|
|
|
|
if ( $wgActorTableSchemaMigrationStage === MIGRATION_NEW ) {
|
|
|
|
|
$res = $dbSecondary->select(
|
|
|
|
|
'actor',
|
|
|
|
|
[ 'actor_id', 'user_id' => 'actor_user', 'user_name' => 'actor_name' ],
|
|
|
|
|
array_merge( [ 'actor_name' => array_keys( $names ) ], $from ? [ "actor_id $from" ] : [] ),
|
|
|
|
|
__METHOD__,
|
|
|
|
|
[ 'ORDER BY' => "actor_name $sort" ]
|
|
|
|
|
);
|
|
|
|
|
$userIter = UserArray::newFromResult( $res );
|
|
|
|
|
} else {
|
|
|
|
|
if ( $wgActorTableSchemaMigrationStage === MIGRATION_OLD ) {
|
|
|
|
|
$res = $dbSecondary->select(
|
|
|
|
|
'user',
|
|
|
|
|
[ 'actor_id' => 'NULL', 'user_id', 'user_name' ],
|
|
|
|
|
array_merge( [ 'user_name' => array_keys( $names ) ], $from ? [ "user_name $from" ] : [] ),
|
|
|
|
|
__METHOD__
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
$res = $dbSecondary->select(
|
|
|
|
|
[ 'user', 'actor' ],
|
|
|
|
|
[ 'actor_id', 'user_id', 'user_name' ],
|
|
|
|
|
array_merge( [ 'user_name' => array_keys( $names ) ], $from ? [ "user_name $from" ] : [] ),
|
|
|
|
|
__METHOD__,
|
|
|
|
|
[],
|
|
|
|
|
[ 'actor' => [ 'LEFT JOIN', 'actor_user = user_id' ] ]
|
|
|
|
|
);
|
|
|
|
|
}
|
2016-03-28 20:20:24 +00:00
|
|
|
foreach ( $res as $row ) {
|
2017-09-12 17:12:29 +00:00
|
|
|
$names[$row->user_name] = $row;
|
2016-03-28 20:20:24 +00:00
|
|
|
}
|
2017-09-12 17:12:29 +00:00
|
|
|
call_user_func_array(
|
|
|
|
|
$this->params['dir'] == 'newer' ? 'ksort' : 'krsort', [ &$names, SORT_STRING ]
|
|
|
|
|
);
|
|
|
|
|
$neg = $op === '>' ? -1 : 1;
|
|
|
|
|
$userIter = call_user_func( function () use ( $names, $fromName, $neg ) {
|
|
|
|
|
foreach ( $names as $name => $row ) {
|
|
|
|
|
if ( $fromName === false || $neg * strcmp( $name, $fromName ) <= 0 ) {
|
|
|
|
|
$user = $row ? User::newFromRow( $row ) : User::newFromName( $name, false );
|
|
|
|
|
yield $user;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} );
|
2016-03-28 20:20:24 +00:00
|
|
|
}
|
2017-09-12 17:12:29 +00:00
|
|
|
$batchSize = count( $names );
|
2008-02-26 16:56:08 +00:00
|
|
|
}
|
2011-04-10 21:52:34 +00:00
|
|
|
|
2017-09-12 17:12:29 +00:00
|
|
|
// During migration, force ordering on the client side because we're
|
|
|
|
|
// having to combine multiple queries that would otherwise have
|
|
|
|
|
// different sort orders.
|
|
|
|
|
if ( $wgActorTableSchemaMigrationStage === MIGRATION_WRITE_BOTH ||
|
|
|
|
|
$wgActorTableSchemaMigrationStage === MIGRATION_WRITE_NEW
|
|
|
|
|
) {
|
|
|
|
|
$batchSize = 1;
|
|
|
|
|
}
|
2006-11-01 12:07:20 +00:00
|
|
|
|
2017-09-12 17:12:29 +00:00
|
|
|
// With the new schema, the DB query will order by actor so update $this->orderBy to match.
|
|
|
|
|
if ( $batchSize > 1 && $wgActorTableSchemaMigrationStage === MIGRATION_NEW ) {
|
|
|
|
|
$this->orderBy = 'actor';
|
2012-06-16 07:47:11 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-01 12:07:20 +00:00
|
|
|
$count = 0;
|
2007-05-20 23:41:25 +00:00
|
|
|
$limit = $this->params['limit'];
|
2017-09-12 17:12:29 +00:00
|
|
|
$userIter->rewind();
|
|
|
|
|
while ( $userIter->valid() ) {
|
|
|
|
|
$users = [];
|
|
|
|
|
while ( count( $users ) < $batchSize && $userIter->valid() ) {
|
|
|
|
|
$users[] = $userIter->current();
|
|
|
|
|
$userIter->next();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ugh. We have to run the query three times, once for each
|
|
|
|
|
// possible 'orcond' from ActorMigration, and then merge them all
|
|
|
|
|
// together in the proper order. And preserving the correct
|
|
|
|
|
// $hookData for each one.
|
|
|
|
|
// @todo When ActorMigration is removed, this can go back to a
|
|
|
|
|
// single prepare and select.
|
|
|
|
|
$merged = [];
|
|
|
|
|
foreach ( [ 'actor', 'userid', 'username' ] as $which ) {
|
|
|
|
|
if ( $this->prepareQuery( $users, $limit - $count, $which ) ) {
|
|
|
|
|
$hookData = [];
|
|
|
|
|
$res = $this->select( __METHOD__, [], $hookData );
|
|
|
|
|
foreach ( $res as $row ) {
|
|
|
|
|
$merged[] = [ $row, &$hookData ];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$neg = $this->params['dir'] == 'newer' ? 1 : -1;
|
|
|
|
|
usort( $merged, function ( $a, $b ) use ( $neg, $batchSize ) {
|
|
|
|
|
if ( $batchSize === 1 ) { // One user, can't be different
|
|
|
|
|
$ret = 0;
|
|
|
|
|
} elseif ( $this->orderBy === 'id' ) {
|
|
|
|
|
$ret = $a[0]->rev_user - $b[0]->rev_user;
|
|
|
|
|
} elseif ( $this->orderBy === 'name' ) {
|
|
|
|
|
$ret = strcmp( $a[0]->rev_user_text, $b[0]->rev_user_text );
|
|
|
|
|
} else {
|
|
|
|
|
$ret = $a[0]->rev_actor - $b[0]->rev_actor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !$ret ) {
|
|
|
|
|
$ret = strcmp(
|
|
|
|
|
wfTimestamp( TS_MW, $a[0]->rev_timestamp ),
|
|
|
|
|
wfTimestamp( TS_MW, $b[0]->rev_timestamp )
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !$ret ) {
|
|
|
|
|
$ret = $a[0]->rev_id - $b[0]->rev_id;
|
|
|
|
|
}
|
2006-11-01 12:07:20 +00:00
|
|
|
|
2017-09-12 17:12:29 +00:00
|
|
|
return $neg * $ret;
|
|
|
|
|
} );
|
|
|
|
|
$merged = array_slice( $merged, 0, $limit - $count + 1 );
|
|
|
|
|
// (end "Ugh")
|
|
|
|
|
|
|
|
|
|
if ( $this->fld_sizediff ) {
|
|
|
|
|
$revIds = [];
|
|
|
|
|
foreach ( $merged as $data ) {
|
|
|
|
|
if ( $data[0]->rev_parent_id ) {
|
|
|
|
|
$revIds[] = $data[0]->rev_parent_id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$this->parentLens = Revision::getParentLengths( $dbSecondary, $revIds );
|
2006-11-01 12:07:20 +00:00
|
|
|
}
|
|
|
|
|
|
2017-09-12 17:12:29 +00:00
|
|
|
foreach ( $merged as $data ) {
|
|
|
|
|
$row = $data[0];
|
|
|
|
|
$hookData = &$data[1];
|
|
|
|
|
if ( ++$count > $limit ) {
|
|
|
|
|
// We've reached the one extra which shows that there are
|
|
|
|
|
// additional pages to be had. Stop here...
|
|
|
|
|
$this->setContinueEnumParameter( 'continue', $this->continueStr( $row ) );
|
|
|
|
|
break 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$vals = $this->extractRowInfo( $row );
|
|
|
|
|
$fit = $this->processRow( $row, $vals, $hookData ) &&
|
|
|
|
|
$this->getResult()->addValue( [ 'query', $this->getModuleName() ], null, $vals );
|
|
|
|
|
if ( !$fit ) {
|
|
|
|
|
$this->setContinueEnumParameter( 'continue', $this->continueStr( $row ) );
|
|
|
|
|
break 2;
|
|
|
|
|
}
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
}
|
2006-11-01 12:07:20 +00:00
|
|
|
}
|
|
|
|
|
|
2017-09-12 17:12:29 +00:00
|
|
|
$this->getResult()->addIndexedTagName( [ 'query', $this->getModuleName() ], 'item' );
|
2006-11-01 12:07:20 +00:00
|
|
|
}
|
|
|
|
|
|
2007-05-20 23:41:25 +00:00
|
|
|
/**
|
|
|
|
|
* Prepares the query and returns the limit of rows requested
|
2017-09-12 17:12:29 +00:00
|
|
|
* @param User[] $users
|
|
|
|
|
* @param int $limit
|
|
|
|
|
* @param string $which 'actor', 'userid', or 'username'
|
|
|
|
|
* @return bool
|
2007-05-20 23:41:25 +00:00
|
|
|
*/
|
2017-09-12 17:12:29 +00:00
|
|
|
private function prepareQuery( array $users, $limit, $which ) {
|
|
|
|
|
global $wgActorTableSchemaMigrationStage;
|
|
|
|
|
|
|
|
|
|
$this->resetQueryParams();
|
|
|
|
|
$db = $this->getDB();
|
|
|
|
|
|
|
|
|
|
$revQuery = Revision::getQueryInfo( [ 'page' ] );
|
|
|
|
|
$this->addTables( $revQuery['tables'] );
|
|
|
|
|
$this->addJoinConds( $revQuery['joins'] );
|
|
|
|
|
$this->addFields( $revQuery['fields'] );
|
|
|
|
|
|
|
|
|
|
$revWhere = ActorMigration::newMigration()->getWhere( $db, 'rev_user', $users );
|
|
|
|
|
if ( !isset( $revWhere['orconds'][$which] ) ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$this->addWhere( $revWhere['orconds'][$which] );
|
|
|
|
|
|
|
|
|
|
if ( $wgActorTableSchemaMigrationStage === MIGRATION_NEW ) {
|
|
|
|
|
$orderUserField = 'rev_actor';
|
|
|
|
|
$userField = $this->orderBy === 'actor' ? 'revactor_actor' : 'actor_name';
|
|
|
|
|
} else {
|
|
|
|
|
$orderUserField = $this->orderBy === 'id' ? 'rev_user' : 'rev_user_text';
|
|
|
|
|
$userField = $revQuery['fields'][$orderUserField];
|
|
|
|
|
}
|
|
|
|
|
if ( $which === 'actor' ) {
|
|
|
|
|
$tsField = 'revactor_timestamp';
|
|
|
|
|
$idField = 'revactor_rev';
|
|
|
|
|
} else {
|
|
|
|
|
$tsField = 'rev_timestamp';
|
|
|
|
|
$idField = 'rev_id';
|
|
|
|
|
}
|
2009-01-19 16:04:33 +00:00
|
|
|
|
2008-10-18 10:14:02 +00:00
|
|
|
// Handle continue parameter
|
2013-12-24 20:26:47 +00:00
|
|
|
if ( !is_null( $this->params['continue'] ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$continue = explode( '|', $this->params['continue'] );
|
2013-12-24 20:26:47 +00:00
|
|
|
if ( $this->multiUserMode ) {
|
2016-03-28 20:20:24 +00:00
|
|
|
$this->dieContinueUsageIf( count( $continue ) != 4 );
|
|
|
|
|
$modeFlag = array_shift( $continue );
|
2017-09-12 17:12:29 +00:00
|
|
|
$this->dieContinueUsageIf( $modeFlag !== $this->orderBy );
|
2013-12-24 20:26:47 +00:00
|
|
|
$encUser = $db->addQuotes( array_shift( $continue ) );
|
|
|
|
|
} else {
|
|
|
|
|
$this->dieContinueUsageIf( count( $continue ) != 2 );
|
|
|
|
|
}
|
|
|
|
|
$encTS = $db->addQuotes( $db->timestamp( $continue[0] ) );
|
|
|
|
|
$encId = (int)$continue[1];
|
|
|
|
|
$this->dieContinueUsageIf( $encId != $continue[1] );
|
2010-01-11 15:55:52 +00:00
|
|
|
$op = ( $this->params['dir'] == 'older' ? '<' : '>' );
|
2013-12-24 20:26:47 +00:00
|
|
|
if ( $this->multiUserMode ) {
|
|
|
|
|
$this->addWhere(
|
2016-03-28 20:20:24 +00:00
|
|
|
"$userField $op $encUser OR " .
|
|
|
|
|
"($userField = $encUser AND " .
|
2017-09-12 17:12:29 +00:00
|
|
|
"($tsField $op $encTS OR " .
|
|
|
|
|
"($tsField = $encTS AND " .
|
|
|
|
|
"$idField $op= $encId)))"
|
2013-12-24 20:26:47 +00:00
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
$this->addWhere(
|
2017-09-12 17:12:29 +00:00
|
|
|
"$tsField $op $encTS OR " .
|
|
|
|
|
"($tsField = $encTS AND " .
|
|
|
|
|
"$idField $op= $encId)"
|
2013-12-24 20:26:47 +00:00
|
|
|
);
|
|
|
|
|
}
|
2008-10-18 10:14:02 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
// Don't include any revisions where we're not supposed to be able to
|
|
|
|
|
// see the username.
|
2017-09-12 17:12:29 +00:00
|
|
|
$user = $this->getUser();
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
if ( !$user->isAllowed( 'deletedhistory' ) ) {
|
|
|
|
|
$bitmask = Revision::DELETED_USER;
|
2014-06-12 22:18:51 +00:00
|
|
|
} elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$bitmask = Revision::DELETED_USER | Revision::DELETED_RESTRICTED;
|
|
|
|
|
} else {
|
|
|
|
|
$bitmask = 0;
|
|
|
|
|
}
|
|
|
|
|
if ( $bitmask ) {
|
2017-09-12 17:12:29 +00:00
|
|
|
$this->addWhere( $db->bitAnd( 'rev_deleted', $bitmask ) . " != $bitmask" );
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
|
2017-09-12 17:12:29 +00:00
|
|
|
// Add the user field to ORDER BY if there are multiple users
|
|
|
|
|
if ( count( $users ) > 1 ) {
|
|
|
|
|
$this->addWhereRange( $orderUserField, $this->params['dir'], null, null );
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2017-09-12 17:12:29 +00:00
|
|
|
|
|
|
|
|
// Then timestamp
|
|
|
|
|
$this->addTimestampWhereRange( $tsField,
|
2007-05-20 23:41:25 +00:00
|
|
|
$this->params['dir'], $this->params['start'], $this->params['end'] );
|
2017-09-12 17:12:29 +00:00
|
|
|
|
|
|
|
|
// Then rev_id for a total ordering
|
|
|
|
|
$this->addWhereRange( $idField, $this->params['dir'], null, null );
|
2013-12-24 20:26:47 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addWhereFld( 'page_namespace', $this->params['namespace'] );
|
2007-07-05 15:09:06 +00:00
|
|
|
|
2007-05-20 23:41:25 +00:00
|
|
|
$show = $this->params['show'];
|
2014-02-26 20:57:58 +00:00
|
|
|
if ( $this->params['toponly'] ) { // deprecated/old param
|
|
|
|
|
$show[] = 'top';
|
|
|
|
|
}
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( !is_null( $show ) ) {
|
|
|
|
|
$show = array_flip( $show );
|
2014-02-26 20:57:58 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( ( isset( $show['minor'] ) && isset( $show['!minor'] ) )
|
2013-11-14 13:00:02 +00:00
|
|
|
|| ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) )
|
2018-03-22 14:17:56 +00:00
|
|
|
|| ( isset( $show['autopatrolled'] ) && isset( $show['!autopatrolled'] ) )
|
|
|
|
|
|| ( isset( $show['autopatrolled'] ) && isset( $show['!patrolled'] ) )
|
2014-02-26 20:57:58 +00:00
|
|
|
|| ( isset( $show['top'] ) && isset( $show['!top'] ) )
|
|
|
|
|
|| ( isset( $show['new'] ) && isset( $show['!new'] ) )
|
2013-11-14 13:00:02 +00:00
|
|
|
) {
|
2016-10-19 16:54:25 +00:00
|
|
|
$this->dieWithError( 'apierror-show' );
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2010-01-11 15:55:52 +00:00
|
|
|
|
|
|
|
|
$this->addWhereIf( 'rev_minor_edit = 0', isset( $show['!minor'] ) );
|
|
|
|
|
$this->addWhereIf( 'rev_minor_edit != 0', isset( $show['minor'] ) );
|
2018-04-11 20:20:55 +00:00
|
|
|
$this->addWhereIf(
|
|
|
|
|
'rc_patrolled = ' . RecentChange::PRC_UNPATROLLED,
|
|
|
|
|
isset( $show['!patrolled'] )
|
|
|
|
|
);
|
|
|
|
|
$this->addWhereIf(
|
|
|
|
|
'rc_patrolled != ' . RecentChange::PRC_UNPATROLLED,
|
|
|
|
|
isset( $show['patrolled'] )
|
|
|
|
|
);
|
|
|
|
|
$this->addWhereIf(
|
|
|
|
|
'rc_patrolled != ' . RecentChange::PRC_AUTOPATROLLED,
|
|
|
|
|
isset( $show['!autopatrolled'] )
|
|
|
|
|
);
|
|
|
|
|
$this->addWhereIf(
|
|
|
|
|
'rc_patrolled = ' . RecentChange::PRC_AUTOPATROLLED,
|
|
|
|
|
isset( $show['autopatrolled'] )
|
|
|
|
|
);
|
2017-09-12 17:12:29 +00:00
|
|
|
$this->addWhereIf( $idField . ' != page_latest', isset( $show['!top'] ) );
|
|
|
|
|
$this->addWhereIf( $idField . ' = page_latest', isset( $show['top'] ) );
|
2014-02-26 20:57:58 +00:00
|
|
|
$this->addWhereIf( 'rev_parent_id != 0', isset( $show['!new'] ) );
|
|
|
|
|
$this->addWhereIf( 'rev_parent_id = 0', isset( $show['new'] ) );
|
2007-05-20 23:41:25 +00:00
|
|
|
}
|
2017-09-12 17:12:29 +00:00
|
|
|
$this->addOption( 'LIMIT', $limit + 1 );
|
2010-02-26 13:18:56 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ||
|
2018-03-22 14:17:56 +00:00
|
|
|
isset( $show['autopatrolled'] ) || isset( $show['!autopatrolled'] ) || $this->fld_patrolled
|
2013-11-14 13:00:02 +00:00
|
|
|
) {
|
2011-10-26 23:27:01 +00:00
|
|
|
if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
|
2016-10-19 16:54:25 +00:00
|
|
|
$this->dieWithError( 'apierror-permissiondenied-patrolflag', 'permissiondenied' );
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2010-07-23 07:33:40 +00:00
|
|
|
|
2018-03-22 14:17:56 +00:00
|
|
|
$isFilterset = isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ||
|
|
|
|
|
isset( $show['autopatrolled'] ) || isset( $show['!autopatrolled'] );
|
2017-09-12 17:12:29 +00:00
|
|
|
$this->addTables( 'recentchanges' );
|
|
|
|
|
$this->addJoinConds( [ 'recentchanges' => [
|
2018-03-22 14:17:56 +00:00
|
|
|
$isFilterset ? 'JOIN' : 'LEFT JOIN',
|
2017-09-12 17:12:29 +00:00
|
|
|
[
|
|
|
|
|
// This is a crazy hack. recentchanges has no index on rc_this_oldid, so instead of adding
|
|
|
|
|
// one T19237 did a join using rc_user_text and rc_timestamp instead. Now rc_user_text is
|
|
|
|
|
// probably unavailable, so just do rc_timestamp.
|
|
|
|
|
'rc_timestamp = ' . $tsField,
|
|
|
|
|
'rc_this_oldid = ' . $idField,
|
|
|
|
|
]
|
|
|
|
|
] ] );
|
2009-01-19 16:04:33 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addFieldsIf( 'rc_patrolled', $this->fld_patrolled );
|
2010-02-26 13:18:56 +00:00
|
|
|
|
|
|
|
|
if ( $this->fld_tags ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addTables( 'tag_summary' );
|
2013-11-14 13:58:14 +00:00
|
|
|
$this->addJoinConds(
|
2017-09-12 17:12:29 +00:00
|
|
|
[ 'tag_summary' => [ 'LEFT JOIN', [ $idField . ' = ts_rev_id' ] ] ]
|
2013-11-14 13:58:14 +00:00
|
|
|
);
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addFields( 'ts_tags' );
|
2009-11-01 10:42:41 +00:00
|
|
|
}
|
2010-02-26 13:18:56 +00:00
|
|
|
|
2010-01-30 12:09:28 +00:00
|
|
|
if ( isset( $this->params['tag'] ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addTables( 'change_tag' );
|
2013-11-14 13:58:14 +00:00
|
|
|
$this->addJoinConds(
|
2017-09-12 17:12:29 +00:00
|
|
|
[ 'change_tag' => [ 'INNER JOIN', [ $idField . ' = ct_rev_id' ] ] ]
|
2013-11-14 13:58:14 +00:00
|
|
|
);
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addWhereFld( 'ct_tag', $this->params['tag'] );
|
2009-11-01 10:42:41 +00:00
|
|
|
}
|
2010-02-26 13:18:56 +00:00
|
|
|
|
2017-09-12 17:12:29 +00:00
|
|
|
return true;
|
2007-05-20 23:41:25 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-05-20 23:41:25 +00:00
|
|
|
/**
|
|
|
|
|
* Extract fields from the database row and append them to a result array
|
2011-09-21 16:36:43 +00:00
|
|
|
*
|
2014-07-03 19:29:02 +00:00
|
|
|
* @param stdClass $row
|
2011-09-21 16:36:43 +00:00
|
|
|
* @return array
|
2007-05-20 23:41:25 +00:00
|
|
|
*/
|
2010-01-11 15:55:52 +00:00
|
|
|
private function extractRowInfo( $row ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$vals = [];
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$anyHidden = false;
|
|
|
|
|
|
|
|
|
|
if ( $row->rev_deleted & Revision::DELETED_TEXT ) {
|
2015-01-16 19:00:07 +00:00
|
|
|
$vals['texthidden'] = true;
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$anyHidden = true;
|
|
|
|
|
}
|
2007-05-20 23:41:25 +00:00
|
|
|
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
// Any rows where we can't view the user were filtered out in the query.
|
2015-05-06 15:33:08 +00:00
|
|
|
$vals['userid'] = (int)$row->rev_user;
|
2008-02-05 15:40:58 +00:00
|
|
|
$vals['user'] = $row->rev_user_text;
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( $row->rev_deleted & Revision::DELETED_USER ) {
|
2015-01-16 19:00:07 +00:00
|
|
|
$vals['userhidden'] = true;
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$anyHidden = true;
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $this->fld_ids ) {
|
|
|
|
|
$vals['pageid'] = intval( $row->rev_page );
|
|
|
|
|
$vals['revid'] = intval( $row->rev_id );
|
2010-02-26 13:18:56 +00:00
|
|
|
// $vals['textid'] = intval( $row->rev_text_id ); // todo: Should this field be exposed?
|
2013-04-23 21:01:32 +00:00
|
|
|
|
|
|
|
|
if ( !is_null( $row->rev_parent_id ) ) {
|
|
|
|
|
$vals['parentid'] = intval( $row->rev_parent_id );
|
|
|
|
|
}
|
2007-05-21 04:34:48 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2010-02-01 15:36:14 +00:00
|
|
|
$title = Title::makeTitle( $row->page_namespace, $row->page_title );
|
2010-01-31 23:06:35 +00:00
|
|
|
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( $this->fld_title ) {
|
2010-02-01 15:36:14 +00:00
|
|
|
ApiQueryBase::addTitleInfo( $vals, $title );
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2007-05-20 23:41:25 +00:00
|
|
|
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( $this->fld_timestamp ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->rev_timestamp );
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2007-05-20 23:41:25 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $this->fld_flags ) {
|
2015-01-16 19:00:07 +00:00
|
|
|
$vals['new'] = $row->rev_parent_id == 0 && !is_null( $row->rev_parent_id );
|
|
|
|
|
$vals['minor'] = (bool)$row->rev_minor_edit;
|
|
|
|
|
$vals['top'] = $row->page_latest == $row->rev_id;
|
2007-05-20 23:41:25 +00:00
|
|
|
}
|
|
|
|
|
|
2017-06-06 17:39:14 +00:00
|
|
|
if ( $this->fld_comment || $this->fld_parsedcomment ) {
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( $row->rev_deleted & Revision::DELETED_COMMENT ) {
|
2015-01-16 19:00:07 +00:00
|
|
|
$vals['commenthidden'] = true;
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
$anyHidden = true;
|
|
|
|
|
}
|
2014-02-05 10:20:17 +00:00
|
|
|
|
|
|
|
|
$userCanView = Revision::userCanBitfield(
|
|
|
|
|
$row->rev_deleted,
|
|
|
|
|
Revision::DELETED_COMMENT, $this->getUser()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if ( $userCanView ) {
|
2018-01-24 23:41:01 +00:00
|
|
|
$comment = $this->commentStore->getComment( 'rev_comment', $row )->text;
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( $this->fld_comment ) {
|
2017-06-06 17:39:14 +00:00
|
|
|
$vals['comment'] = $comment;
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
2010-01-31 23:06:35 +00:00
|
|
|
if ( $this->fld_parsedcomment ) {
|
2017-06-06 17:39:14 +00:00
|
|
|
$vals['parsedcomment'] = Linker::formatComment( $comment, $title );
|
2010-01-31 23:06:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-04-22 09:21:33 +00:00
|
|
|
}
|
2007-05-20 23:41:25 +00:00
|
|
|
|
2015-01-16 19:00:07 +00:00
|
|
|
if ( $this->fld_patrolled ) {
|
2018-03-22 14:17:56 +00:00
|
|
|
$vals['patrolled'] = $row->rc_patrolled != RecentChange::PRC_UNPATROLLED;
|
|
|
|
|
$vals['autopatrolled'] = $row->rc_patrolled == RecentChange::PRC_AUTOPATROLLED;
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $this->fld_size && !is_null( $row->rev_len ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$vals['size'] = intval( $row->rev_len );
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2009-01-19 16:04:33 +00:00
|
|
|
|
2013-11-14 13:58:14 +00:00
|
|
|
if ( $this->fld_sizediff
|
|
|
|
|
&& !is_null( $row->rev_len )
|
|
|
|
|
&& !is_null( $row->rev_parent_id )
|
|
|
|
|
) {
|
|
|
|
|
$parentLen = isset( $this->parentLens[$row->rev_parent_id] )
|
|
|
|
|
? $this->parentLens[$row->rev_parent_id]
|
|
|
|
|
: 0;
|
2012-06-16 07:47:11 +00:00
|
|
|
$vals['sizediff'] = intval( $row->rev_len - $parentLen );
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $this->fld_tags ) {
|
|
|
|
|
if ( $row->ts_tags ) {
|
|
|
|
|
$tags = explode( ',', $row->ts_tags );
|
API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
2014-12-03 22:14:22 +00:00
|
|
|
ApiResult::setIndexedTagName( $tags, 'tag' );
|
2009-11-01 10:42:41 +00:00
|
|
|
$vals['tags'] = $tags;
|
|
|
|
|
} else {
|
2016-02-17 09:09:32 +00:00
|
|
|
$vals['tags'] = [];
|
2009-11-01 10:42:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-02-26 13:18:56 +00:00
|
|
|
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
if ( $anyHidden && $row->rev_deleted & Revision::DELETED_RESTRICTED ) {
|
2015-01-16 19:00:07 +00:00
|
|
|
$vals['suppressed'] = true;
|
Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
ApiQueryWatchlist will now return entires where fields have been
revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
ApiQueryContributions will now return field values in addition to the
"hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
"suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
entries where the user or action are revision-deleted if the
requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
'hideuser' to determine when to show contributions where the username
was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
the "content" prop along with the "tags" prop or "drtag" parameter
would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
$opts, and now may have an option to indicate the user to use for
RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
checking whether wlprop=patrol is allowed, rather than using the
wlowner's rights.
Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2013-12-18 21:58:39 +00:00
|
|
|
}
|
|
|
|
|
|
2007-05-20 23:41:25 +00:00
|
|
|
return $vals;
|
|
|
|
|
}
|
2010-02-26 13:18:56 +00:00
|
|
|
|
|
|
|
|
private function continueStr( $row ) {
|
2013-12-24 20:26:47 +00:00
|
|
|
if ( $this->multiUserMode ) {
|
2017-09-12 17:12:29 +00:00
|
|
|
switch ( $this->orderBy ) {
|
|
|
|
|
case 'id':
|
|
|
|
|
return "id|$row->rev_user|$row->rev_timestamp|$row->rev_id";
|
|
|
|
|
case 'name':
|
|
|
|
|
return "name|$row->rev_user_text|$row->rev_timestamp|$row->rev_id";
|
|
|
|
|
case 'actor':
|
|
|
|
|
return "actor|$row->rev_actor|$row->rev_timestamp|$row->rev_id";
|
2016-03-28 20:20:24 +00:00
|
|
|
}
|
2013-12-24 20:26:47 +00:00
|
|
|
} else {
|
|
|
|
|
return "$row->rev_timestamp|$row->rev_id";
|
|
|
|
|
}
|
2008-10-18 10:14:02 +00:00
|
|
|
}
|
2007-05-20 23:41:25 +00:00
|
|
|
|
2010-07-23 07:17:56 +00:00
|
|
|
public function getCacheMode( $params ) {
|
|
|
|
|
// This module provides access to deleted revisions and patrol flags if
|
|
|
|
|
// the requester is logged in
|
|
|
|
|
return 'anon-public-user-private';
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getAllowedParams() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
|
|
|
|
'limit' => [
|
2010-02-26 13:18:56 +00:00
|
|
|
ApiBase::PARAM_DFLT => 10,
|
|
|
|
|
ApiBase::PARAM_TYPE => 'limit',
|
|
|
|
|
ApiBase::PARAM_MIN => 1,
|
|
|
|
|
ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
|
|
|
|
|
ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'start' => [
|
2010-02-26 13:18:56 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'timestamp'
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'end' => [
|
2010-02-26 13:18:56 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'timestamp'
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'continue' => [
|
2014-09-18 17:38:23 +00:00
|
|
|
ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'user' => [
|
2016-01-04 18:55:26 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'user',
|
2010-02-26 13:18:56 +00:00
|
|
|
ApiBase::PARAM_ISMULTI => true
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2016-11-29 22:34:21 +00:00
|
|
|
'userids' => [
|
|
|
|
|
ApiBase::PARAM_TYPE => 'integer',
|
|
|
|
|
ApiBase::PARAM_ISMULTI => true
|
|
|
|
|
],
|
2008-02-26 16:56:08 +00:00
|
|
|
'userprefix' => null,
|
2016-02-17 09:09:32 +00:00
|
|
|
'dir' => [
|
2010-02-26 13:18:56 +00:00
|
|
|
ApiBase::PARAM_DFLT => 'older',
|
2016-02-17 09:09:32 +00:00
|
|
|
ApiBase::PARAM_TYPE => [
|
2006-11-01 12:07:20 +00:00
|
|
|
'newer',
|
|
|
|
|
'older'
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2014-09-18 17:38:23 +00:00
|
|
|
ApiBase::PARAM_HELP_MSG => 'api-help-param-direction',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'namespace' => [
|
2010-02-26 13:18:56 +00:00
|
|
|
ApiBase::PARAM_ISMULTI => true,
|
|
|
|
|
ApiBase::PARAM_TYPE => 'namespace'
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'prop' => [
|
2010-02-26 13:18:56 +00:00
|
|
|
ApiBase::PARAM_ISMULTI => true,
|
|
|
|
|
ApiBase::PARAM_DFLT => 'ids|title|timestamp|comment|size|flags',
|
2016-02-17 09:09:32 +00:00
|
|
|
ApiBase::PARAM_TYPE => [
|
2007-05-21 04:34:48 +00:00
|
|
|
'ids',
|
2007-05-20 23:41:25 +00:00
|
|
|
'title',
|
|
|
|
|
'timestamp',
|
|
|
|
|
'comment',
|
2010-01-31 23:06:35 +00:00
|
|
|
'parsedcomment',
|
2009-05-10 09:25:46 +00:00
|
|
|
'size',
|
2012-06-16 07:47:11 +00:00
|
|
|
'sizediff',
|
2009-01-19 16:04:33 +00:00
|
|
|
'flags',
|
2009-02-04 23:19:18 +00:00
|
|
|
'patrolled',
|
2009-11-01 10:42:41 +00:00
|
|
|
'tags'
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
|
|
|
|
|
],
|
|
|
|
|
'show' => [
|
2010-02-26 13:18:56 +00:00
|
|
|
ApiBase::PARAM_ISMULTI => true,
|
2016-02-17 09:09:32 +00:00
|
|
|
ApiBase::PARAM_TYPE => [
|
2007-05-20 23:41:25 +00:00
|
|
|
'minor',
|
|
|
|
|
'!minor',
|
2009-02-04 23:19:18 +00:00
|
|
|
'patrolled',
|
|
|
|
|
'!patrolled',
|
2018-03-22 14:17:56 +00:00
|
|
|
'autopatrolled',
|
|
|
|
|
'!autopatrolled',
|
2014-02-26 20:57:58 +00:00
|
|
|
'top',
|
|
|
|
|
'!top',
|
|
|
|
|
'new',
|
|
|
|
|
'!new',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
ApiBase::PARAM_HELP_MSG => [
|
2014-09-18 17:38:23 +00:00
|
|
|
'apihelp-query+usercontribs-param-show',
|
|
|
|
|
$this->getConfig()->get( 'RCMaxAge' )
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
2010-02-03 23:30:19 +00:00
|
|
|
'tag' => null,
|
2016-02-17 09:09:32 +00:00
|
|
|
'toponly' => [
|
2014-02-26 20:57:58 +00:00
|
|
|
ApiBase::PARAM_DFLT => false,
|
|
|
|
|
ApiBase::PARAM_DEPRECATED => true,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
];
|
2006-11-01 12:07:20 +00:00
|
|
|
}
|
|
|
|
|
|
2014-10-28 17:17:02 +00:00
|
|
|
protected function getExamplesMessages() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2014-09-18 17:38:23 +00:00
|
|
|
'action=query&list=usercontribs&ucuser=Example'
|
|
|
|
|
=> 'apihelp-query+usercontribs-example-user',
|
|
|
|
|
'action=query&list=usercontribs&ucuserprefix=192.0.2.'
|
|
|
|
|
=> 'apihelp-query+usercontribs-example-ipprefix',
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2006-11-01 12:07:20 +00:00
|
|
|
}
|
|
|
|
|
|
2011-07-17 17:02:06 +00:00
|
|
|
public function getHelpUrls() {
|
2017-04-04 22:52:57 +00:00
|
|
|
return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Usercontribs';
|
2011-07-17 17:02:06 +00:00
|
|
|
}
|
2009-05-15 10:42:25 +00:00
|
|
|
}
|
2018-05-25 00:46:30 +00:00
|
|
|
|
2018-05-29 16:21:31 +00:00
|
|
|
/**
|
|
|
|
|
* @since 1.9
|
|
|
|
|
* @deprecated since 1.32
|
|
|
|
|
*/
|
2018-05-25 00:46:30 +00:00
|
|
|
class_alias( ApiQueryUserContribs::class, 'ApiQueryContributions' );
|