35 parent::__construct(
$query, $moduleName,
'arv' );
45 $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
54 $needPageTable =
false;
55 if (
$params[
'namespace'] !==
null ) {
58 if (
$params[
'namespace'] != MWNamespace::getValidNamespaces() ) {
59 $needPageTable =
true;
60 if ( $this->
getConfig()->
get(
'MiserMode' ) ) {
61 $miser_ns =
$params[
'namespace'];
68 if ( $resultPageSet ===
null ) {
71 $this->fetchContent ? [
'page',
'text' ] : [
'page' ]
82 $this->
addFields( [
'rev_timestamp',
'rev_id' ] );
83 if (
$params[
'generatetitles'] ) {
87 if ( $needPageTable ) {
90 [
'page' => [
'INNER JOIN', [
'rev_page = page_id' ] ] ]
92 $this->
addFieldsIf( [
'page_namespace' ], (
bool)$miser_ns );
102 if ( $this->fld_tags ) {
105 [
'tag_summary' => [
'LEFT JOIN', [
'rev_id=ts_rev_id' ] ] ]
110 if (
$params[
'user'] !==
null ) {
111 $actorQuery = ActorMigration::newMigration()
113 $this->
addTables( $actorQuery[
'tables'] );
115 $this->
addWhere( $actorQuery[
'conds'] );
116 } elseif (
$params[
'excludeuser'] !==
null ) {
117 $actorQuery = ActorMigration::newMigration()
119 $this->
addTables( $actorQuery[
'tables'] );
121 $this->
addWhere(
'NOT(' . $actorQuery[
'conds'] .
')' );
124 if (
$params[
'user'] !==
null ||
$params[
'excludeuser'] !==
null ) {
126 if ( !$this->
getUser()->isAllowed(
'deletedhistory' ) ) {
127 $bitmask = RevisionRecord::DELETED_USER;
128 } elseif ( !$this->
getUser()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
129 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
134 $this->
addWhere( $db->bitAnd(
'rev_deleted', $bitmask ) .
" != $bitmask" );
138 if (
$params[
'continue'] !==
null ) {
139 $op = ( $dir ==
'newer' ?
'>' :
'<' );
140 $cont = explode(
'|',
$params[
'continue'] );
142 $ts = $db->addQuotes( $db->timestamp( $cont[0] ) );
143 $rev_id = (int)$cont[1];
145 $this->
addWhere(
"rev_timestamp $op $ts OR " .
146 "(rev_timestamp = $ts AND " .
147 "rev_id $op= $rev_id)" );
150 $this->
addOption(
'LIMIT', $this->limit + 1 );
152 $sort = ( $dir ==
'newer' ?
'' :
' DESC' );
156 $orderby[] =
"rev_timestamp $sort";
157 $orderby[] =
"rev_id $sort";
158 $this->
addOption(
'ORDER BY', $orderby );
161 $res = $this->
select( __METHOD__, [], $hookData );
166 foreach (
$res as $row ) {
167 if ( $count === 0 && $resultPageSet !==
null ) {
171 $this,
'continue',
"$row->rev_timestamp|$row->rev_id"
174 if ( ++$count > $this->limit ) {
181 if ( $miser_ns !==
null && !in_array( $row->page_namespace, $miser_ns ) ) {
185 if ( $resultPageSet !==
null ) {
186 if (
$params[
'generatetitles'] ) {
187 $generated[$row->rev_page] = $row->rev_page;
189 $generated[] = $row->rev_id;
192 $revision = $revisionStore->newRevisionFromRow( $row );
195 if ( !isset( $pageMap[$row->rev_page] ) ) {
196 $index = $nextIndex++;
197 $pageMap[$row->rev_page] = $index;
198 $title = Title::newFromLinkTarget( $revision->getPageAsLinkTarget() );
200 'pageid' => $title->getArticleID(),
201 'revisions' => [
$rev ],
205 $fit = $this->
processRow( $row, $a[
'revisions'][0], $hookData ) &&
206 $result->addValue( [
'query', $this->
getModuleName() ], $index, $a );
208 $index = $pageMap[$row->rev_page];
210 $result->addValue( [
'query', $this->
getModuleName(), $index,
'revisions' ],
null,
$rev );
219 if ( $resultPageSet !==
null ) {
220 if (
$params[
'generatetitles'] ) {
221 $resultPageSet->populateFromPageIDs( $generated );
223 $resultPageSet->populateFromRevisionIDs( $generated );
226 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'page' );
231 $ret = parent::getAllowedParams() + [
260 'generatetitles' => [
265 if ( $this->
getConfig()->
get(
'MiserMode' ) ) {
267 'api-help-param-limited-in-miser-mode',
276 'action=query&list=allrevisions&arvuser=Example&arvlimit=50'
277 =>
'apihelp-query+allrevisions-example-user',
278 'action=query&list=allrevisions&arvdir=newer&arvlimit=50'
279 =>
'apihelp-query+allrevisions-example-ns-main',
284 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allrevisions';
getParameter( $paramName, $parseLimit=true)
Get a value for the given parameter.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
const PARAM_HELP_MSG_APPEND
((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this ...
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
requireMaxOneParameter( $params, $required)
Die if more than one of a certain set of parameters is set and not false.
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
getModuleName()
Get the name of the module being executed by this instance.
getContinuationManager()
Get the continuation manager.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
This class contains a list of pages that the client has requested.
Query module to enumerate all revisions.
getHelpUrls()
Return links to more detailed help pages about the module.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
__construct(ApiQuery $query, $moduleName)
getExamplesMessages()
Returns usage examples for this module.
run(ApiPageSet $resultPageSet=null)
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
processRow( $row, array &$data, array &$hookData)
Call the ApiQueryBaseProcessRow hook.
addFields( $value)
Add a set of fields to select to the internal array.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
addTimestampWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, similar to addWhereRange, but converts $start and $end t...
getDB()
Get the Query database connection (read-only)
addFieldsIf( $value, $condition)
Same as addFields(), but add the fields only if a condition is met.
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
addWhere( $value)
Add a set of WHERE clauses to the internal array.
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
A base class for functions common to producing a list of revisions.
parseParameters( $params)
Parse the parameters into the various instance fields.
extractRevisionInfo(RevisionRecord $revision, $row)
Extract information from the RevisionRecord.
This is the main query class.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like select() and insert() are usually more convenient. They take care of things like table prefixes and escaping for you. If you really need to make your own SQL
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev