MediaWiki REL1_37
ApiQueryUserContribs.php
Go to the documentation of this file.
1<?php
32
39
42
45
48
51
54
57
68 public function __construct(
69 ApiQuery $query,
70 $moduleName,
77 ) {
78 parent::__construct( $query, $moduleName, 'uc' );
79 $this->commentStore = $commentStore;
80 $this->userIdentityLookup = $userIdentityLookup;
81 $this->userNameUtils = $userNameUtils;
82 $this->revisionStore = $revisionStore;
83 $this->changeTagDefStore = $changeTagDefStore;
84 $this->actorMigration = $actorMigration;
85 }
86
88
89 private $fld_ids = false, $fld_title = false, $fld_timestamp = false,
90 $fld_comment = false, $fld_parsedcomment = false, $fld_flags = false,
91 $fld_patrolled = false, $fld_tags = false, $fld_size = false, $fld_sizediff = false;
92
93 public function execute() {
94 // Parse some parameters
95 $this->params = $this->extractRequestParams();
96
97 $prop = array_fill_keys( $this->params['prop'], true );
98 $this->fld_ids = isset( $prop['ids'] );
99 $this->fld_title = isset( $prop['title'] );
100 $this->fld_comment = isset( $prop['comment'] );
101 $this->fld_parsedcomment = isset( $prop['parsedcomment'] );
102 $this->fld_size = isset( $prop['size'] );
103 $this->fld_sizediff = isset( $prop['sizediff'] );
104 $this->fld_flags = isset( $prop['flags'] );
105 $this->fld_timestamp = isset( $prop['timestamp'] );
106 $this->fld_patrolled = isset( $prop['patrolled'] );
107 $this->fld_tags = isset( $prop['tags'] );
108
109 // The main query may use the 'contributions' group DB, which can map to replica DBs
110 // with extra user based indexes or partioning by user. The additional metadata
111 // queries should use a regular replica DB since the lookup pattern is not all by user.
112 $dbSecondary = $this->getDB(); // any random replica DB
113
114 $sort = ( $this->params['dir'] == 'newer' ?
115 SelectQueryBuilder::SORT_ASC : SelectQueryBuilder::SORT_DESC );
116 $op = ( $this->params['dir'] == 'older' ? '<' : '>' );
117
118 // Create an Iterator that produces the UserIdentity objects we need, depending
119 // on which of the 'userprefix', 'userids', or 'user' params was
120 // specified.
121 $this->requireOnlyOneParameter( $this->params, 'userprefix', 'userids', 'user' );
122 if ( isset( $this->params['userprefix'] ) ) {
123 $this->multiUserMode = true;
124 $this->orderBy = 'name';
125 $fname = __METHOD__;
126
127 // Because 'userprefix' might produce a huge number of users (e.g.
128 // a wiki with users "Test00000001" to "Test99999999"), use a
129 // generator with batched lookup and continuation.
130 $userIter = call_user_func( function () use ( $dbSecondary, $sort, $op, $fname ) {
131 $fromName = false;
132 if ( $this->params['continue'] !== null ) {
133 $continue = explode( '|', $this->params['continue'] );
134 $this->dieContinueUsageIf( count( $continue ) != 4 );
135 $this->dieContinueUsageIf( $continue[0] !== 'name' );
136 $fromName = $continue[1];
137 }
138
139 $limit = 501;
140 do {
141 $from = $fromName ? "$op= " . $dbSecondary->addQuotes( $fromName ) : false;
142 $usersBatch = $this->userIdentityLookup
143 ->newSelectQueryBuilder()
144 ->caller( $fname )
145 ->limit( $limit )
146 ->whereUserNamePrefix( $this->params['userprefix'] )
147 ->where( $from ? [ "actor_name $from" ] : [] )
148 ->orderByName( $sort )
149 ->fetchUserIdentities();
150
151 $count = 0;
152 $fromName = false;
153 foreach ( $usersBatch as $user ) {
154 if ( ++$count >= $limit ) {
155 $fromName = $user->getName();
156 break;
157 }
158 yield $user;
159 }
160 } while ( $fromName !== false );
161 } );
162 // Do the actual sorting client-side, because otherwise
163 // prepareQuery might try to sort by actor and confuse everything.
164 $batchSize = 1;
165 } elseif ( isset( $this->params['userids'] ) ) {
166 if ( $this->params['userids'] === [] ) {
167 $encParamName = $this->encodeParamName( 'userids' );
168 $this->dieWithError( [ 'apierror-paramempty', $encParamName ], "paramempty_$encParamName" );
169 }
170
171 $ids = [];
172 foreach ( $this->params['userids'] as $uid ) {
173 if ( $uid <= 0 ) {
174 $this->dieWithError( [ 'apierror-invaliduserid', $uid ], 'invaliduserid' );
175 }
176 $ids[] = $uid;
177 }
178
179 $this->orderBy = 'id';
180 $this->multiUserMode = count( $ids ) > 1;
181
182 $from = $fromId = false;
183 if ( $this->multiUserMode && $this->params['continue'] !== null ) {
184 $continue = explode( '|', $this->params['continue'] );
185 $this->dieContinueUsageIf( count( $continue ) != 4 );
186 $this->dieContinueUsageIf( $continue[0] !== 'id' && $continue[0] !== 'actor' );
187 $fromId = (int)$continue[1];
188 $this->dieContinueUsageIf( $continue[1] !== (string)$fromId );
189 $from = "$op= $fromId";
190 }
191
192 $userIter = $this->userIdentityLookup
193 ->newSelectQueryBuilder()
194 ->caller( __METHOD__ )
195 ->whereUserIds( $ids )
196 ->orderByUserId( $sort )
197 ->where( $from ? [ "actor_id $from" ] : [] )
198 ->fetchUserIdentities();
199 $batchSize = count( $ids );
200 } else {
201 $names = [];
202 if ( !count( $this->params['user'] ) ) {
203 $encParamName = $this->encodeParamName( 'user' );
204 $this->dieWithError(
205 [ 'apierror-paramempty', $encParamName ], "paramempty_$encParamName"
206 );
207 }
208 foreach ( $this->params['user'] as $u ) {
209 if ( $u === '' ) {
210 $encParamName = $this->encodeParamName( 'user' );
211 $this->dieWithError(
212 [ 'apierror-paramempty', $encParamName ], "paramempty_$encParamName"
213 );
214 }
215
216 if ( $this->userNameUtils->isIP( $u ) || ExternalUserNames::isExternal( $u ) ) {
217 $names[$u] = null;
218 } else {
219 $name = $this->userNameUtils->getCanonical( $u );
220 if ( $name === false ) {
221 $encParamName = $this->encodeParamName( 'user' );
222 $this->dieWithError(
223 [ 'apierror-baduser', $encParamName, wfEscapeWikiText( $u ) ], "baduser_$encParamName"
224 );
225 }
226 $names[$name] = null;
227 }
228 }
229
230 $this->orderBy = 'name';
231 $this->multiUserMode = count( $names ) > 1;
232
233 $from = $fromName = false;
234 if ( $this->multiUserMode && $this->params['continue'] !== null ) {
235 $continue = explode( '|', $this->params['continue'] );
236 $this->dieContinueUsageIf( count( $continue ) != 4 );
237 $this->dieContinueUsageIf( $continue[0] !== 'name' && $continue[0] !== 'actor' );
238 $fromName = $continue[1];
239 $from = "$op= " . $dbSecondary->addQuotes( $fromName );
240 }
241
242 $userIter = $this->userIdentityLookup
243 ->newSelectQueryBuilder()
244 ->caller( __METHOD__ )
245 ->whereUserNames( array_keys( $names ) )
246 ->where( $from ? [ "actor_id $from" ] : [] )
247 ->orderByName( $sort )
248 ->fetchUserIdentities();
249 $batchSize = count( $names );
250 }
251
252 // The DB query will order by actor so update $this->orderBy to match.
253 if ( $batchSize > 1 ) {
254 $this->orderBy = 'actor';
255 }
256
257 $count = 0;
258 $limit = $this->params['limit'];
259 $userIter->rewind();
260 while ( $userIter->valid() ) {
261 $users = [];
262 while ( count( $users ) < $batchSize && $userIter->valid() ) {
263 $users[] = $userIter->current();
264 $userIter->next();
265 }
266
267 $hookData = [];
268 $this->prepareQuery( $users, $limit - $count );
269 $res = $this->select( __METHOD__, [], $hookData );
270
271 if ( $this->fld_title ) {
272 $this->executeGenderCacheFromResultWrapper( $res, __METHOD__ );
273 }
274
275 if ( $this->fld_sizediff ) {
276 $revIds = [];
277 foreach ( $res as $row ) {
278 if ( $row->rev_parent_id ) {
279 $revIds[] = $row->rev_parent_id;
280 }
281 }
282 $this->parentLens = $this->revisionStore->getRevisionSizes( $revIds );
283 }
284
285 foreach ( $res as $row ) {
286 if ( ++$count > $limit ) {
287 // We've reached the one extra which shows that there are
288 // additional pages to be had. Stop here...
289 $this->setContinueEnumParameter( 'continue', $this->continueStr( $row ) );
290 break 2;
291 }
292
293 $vals = $this->extractRowInfo( $row );
294 $fit = $this->processRow( $row, $vals, $hookData ) &&
295 $this->getResult()->addValue( [ 'query', $this->getModuleName() ], null, $vals );
296 if ( !$fit ) {
297 $this->setContinueEnumParameter( 'continue', $this->continueStr( $row ) );
298 break 2;
299 }
300 }
301 }
302
303 $this->getResult()->addIndexedTagName( [ 'query', $this->getModuleName() ], 'item' );
304 }
305
311 private function prepareQuery( array $users, $limit ) {
313
314 $this->resetQueryParams();
315 $db = $this->getDB();
316
317 $revQuery = $this->revisionStore->getQueryInfo( [ 'page' ] );
318 $revWhere = $this->actorMigration->getWhere( $db, 'rev_user', $users );
319
321 $orderUserField = 'rev_actor';
322 $userField = $this->orderBy === 'actor' ? 'revactor_actor' : 'actor_name';
323 $tsField = 'revactor_timestamp';
324 $idField = 'revactor_rev';
325
326 // T221511: MySQL/MariaDB (10.1.37) can sometimes irrationally decide that querying `actor`
327 // before `revision_actor_temp` and filesorting is somehow better than querying $limit+1 rows
328 // from `revision_actor_temp`. Tell it not to reorder the query (and also reorder it ourselves
329 // because as generated by RevisionStore it'll have `revision` first rather than
330 // `revision_actor_temp`). But not when uctag is used, as it seems as likely to be harmed as
331 // helped in that case, and not when there's only one User because in that case it fetches
332 // the one `actor` row as a constant and doesn't filesort.
333 if ( count( $users ) > 1 && !isset( $this->params['tag'] ) ) {
334 $revQuery['joins']['revision'] = $revQuery['joins']['temp_rev_user'];
335 unset( $revQuery['joins']['temp_rev_user'] );
336 $this->addOption( 'STRAIGHT_JOIN' );
337 // It isn't actually necesssary to reorder $revQuery['tables'] as Database does the right thing
338 // when join conditions are given for all joins, but Gergő is wary of relying on that so pull
339 // `revision_actor_temp` to the start.
340 $revQuery['tables'] =
341 [ 'temp_rev_user' => $revQuery['tables']['temp_rev_user'] ] + $revQuery['tables'];
342 }
343 } else /* SCHEMA_COMPAT_READ_NEW */ {
344 $orderUserField = 'rev_actor';
345 $userField = $this->orderBy === 'actor' ? 'rev_actor' : 'actor_name';
346 $tsField = 'rev_timestamp';
347 $idField = 'rev_id';
348 }
349
350 $this->addTables( $revQuery['tables'] );
351 $this->addJoinConds( $revQuery['joins'] );
352 $this->addFields( $revQuery['fields'] );
353 $this->addWhere( $revWhere['conds'] );
354
355 // Handle continue parameter
356 if ( $this->params['continue'] !== null ) {
357 $continue = explode( '|', $this->params['continue'] );
358 if ( $this->multiUserMode ) {
359 $this->dieContinueUsageIf( count( $continue ) != 4 );
360 $modeFlag = array_shift( $continue );
361 $this->dieContinueUsageIf( $modeFlag !== $this->orderBy );
362 $encUser = $db->addQuotes( array_shift( $continue ) );
363 } else {
364 $this->dieContinueUsageIf( count( $continue ) != 2 );
365 }
366 $encTS = $db->addQuotes( $db->timestamp( $continue[0] ) );
367 $encId = (int)$continue[1];
368 $this->dieContinueUsageIf( $encId != $continue[1] );
369 $op = ( $this->params['dir'] == 'older' ? '<' : '>' );
370 if ( $this->multiUserMode ) {
371 $this->addWhere(
372 "$userField $op $encUser OR " .
373 "($userField = $encUser AND " .
374 "($tsField $op $encTS OR " .
375 "($tsField = $encTS AND " .
376 "$idField $op= $encId)))"
377 );
378 } else {
379 $this->addWhere(
380 "$tsField $op $encTS OR " .
381 "($tsField = $encTS AND " .
382 "$idField $op= $encId)"
383 );
384 }
385 }
386
387 // Don't include any revisions where we're not supposed to be able to
388 // see the username.
389 if ( !$this->getAuthority()->isAllowed( 'deletedhistory' ) ) {
390 $bitmask = RevisionRecord::DELETED_USER;
391 } elseif ( !$this->getAuthority()->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
392 $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
393 } else {
394 $bitmask = 0;
395 }
396 if ( $bitmask ) {
397 $this->addWhere( $db->bitAnd( 'rev_deleted', $bitmask ) . " != $bitmask" );
398 }
399
400 // Add the user field to ORDER BY if there are multiple users
401 if ( count( $users ) > 1 ) {
402 $this->addWhereRange( $orderUserField, $this->params['dir'], null, null );
403 }
404
405 // Then timestamp
406 $this->addTimestampWhereRange( $tsField,
407 $this->params['dir'], $this->params['start'], $this->params['end'] );
408
409 // Then rev_id for a total ordering
410 $this->addWhereRange( $idField, $this->params['dir'], null, null );
411
412 $this->addWhereFld( 'page_namespace', $this->params['namespace'] );
413
414 $show = $this->params['show'];
415 if ( $this->params['toponly'] ) { // deprecated/old param
416 $show[] = 'top';
417 }
418 if ( $show !== null ) {
419 $show = array_fill_keys( $show, true );
420
421 if ( ( isset( $show['minor'] ) && isset( $show['!minor'] ) )
422 || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) )
423 || ( isset( $show['autopatrolled'] ) && isset( $show['!autopatrolled'] ) )
424 || ( isset( $show['autopatrolled'] ) && isset( $show['!patrolled'] ) )
425 || ( isset( $show['top'] ) && isset( $show['!top'] ) )
426 || ( isset( $show['new'] ) && isset( $show['!new'] ) )
427 ) {
428 $this->dieWithError( 'apierror-show' );
429 }
430
431 $this->addWhereIf( 'rev_minor_edit = 0', isset( $show['!minor'] ) );
432 $this->addWhereIf( 'rev_minor_edit != 0', isset( $show['minor'] ) );
433 $this->addWhereIf(
434 'rc_patrolled = ' . RecentChange::PRC_UNPATROLLED,
435 isset( $show['!patrolled'] )
436 );
437 $this->addWhereIf(
438 'rc_patrolled != ' . RecentChange::PRC_UNPATROLLED,
439 isset( $show['patrolled'] )
440 );
441 $this->addWhereIf(
442 'rc_patrolled != ' . RecentChange::PRC_AUTOPATROLLED,
443 isset( $show['!autopatrolled'] )
444 );
445 $this->addWhereIf(
446 'rc_patrolled = ' . RecentChange::PRC_AUTOPATROLLED,
447 isset( $show['autopatrolled'] )
448 );
449 $this->addWhereIf( $idField . ' != page_latest', isset( $show['!top'] ) );
450 $this->addWhereIf( $idField . ' = page_latest', isset( $show['top'] ) );
451 $this->addWhereIf( 'rev_parent_id != 0', isset( $show['!new'] ) );
452 $this->addWhereIf( 'rev_parent_id = 0', isset( $show['new'] ) );
453 }
454 $this->addOption( 'LIMIT', $limit + 1 );
455
456 if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ||
457 isset( $show['autopatrolled'] ) || isset( $show['!autopatrolled'] ) || $this->fld_patrolled
458 ) {
459 $user = $this->getUser();
460 if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
461 $this->dieWithError( 'apierror-permissiondenied-patrolflag', 'permissiondenied' );
462 }
463
464 $isFilterset = isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ||
465 isset( $show['autopatrolled'] ) || isset( $show['!autopatrolled'] );
466 $this->addTables( 'recentchanges' );
467 $this->addJoinConds( [ 'recentchanges' => [
468 $isFilterset ? 'JOIN' : 'LEFT JOIN',
469 [ 'rc_this_oldid = ' . $idField ]
470 ] ] );
471 }
472
473 $this->addFieldsIf( 'rc_patrolled', $this->fld_patrolled );
474
475 if ( $this->fld_tags ) {
476 $this->addFields( [ 'ts_tags' => ChangeTags::makeTagSummarySubquery( 'revision' ) ] );
477 }
478
479 if ( isset( $this->params['tag'] ) ) {
480 $this->addTables( 'change_tag' );
481 $this->addJoinConds(
482 [ 'change_tag' => [ 'JOIN', [ $idField . ' = ct_rev_id' ] ] ]
483 );
484 try {
485 $this->addWhereFld( 'ct_tag_id', $this->changeTagDefStore->getId( $this->params['tag'] ) );
486 } catch ( NameTableAccessException $exception ) {
487 // Return nothing.
488 $this->addWhere( '1=0' );
489 }
490 }
491 $this->addOption(
492 'MAX_EXECUTION_TIME',
493 $this->getConfig()->get( 'MaxExecutionTimeForExpensiveQueries' )
494 );
495 }
496
503 private function extractRowInfo( $row ) {
504 $vals = [];
505 $anyHidden = false;
506
507 if ( $row->rev_deleted & RevisionRecord::DELETED_TEXT ) {
508 $vals['texthidden'] = true;
509 $anyHidden = true;
510 }
511
512 // Any rows where we can't view the user were filtered out in the query.
513 $vals['userid'] = (int)$row->rev_user;
514 $vals['user'] = $row->rev_user_text;
515 if ( $row->rev_deleted & RevisionRecord::DELETED_USER ) {
516 $vals['userhidden'] = true;
517 $anyHidden = true;
518 }
519 if ( $this->fld_ids ) {
520 $vals['pageid'] = (int)$row->rev_page;
521 $vals['revid'] = (int)$row->rev_id;
522
523 if ( $row->rev_parent_id !== null ) {
524 $vals['parentid'] = (int)$row->rev_parent_id;
525 }
526 }
527
528 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
529
530 if ( $this->fld_title ) {
532 }
533
534 if ( $this->fld_timestamp ) {
535 $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->rev_timestamp );
536 }
537
538 if ( $this->fld_flags ) {
539 $vals['new'] = $row->rev_parent_id == 0 && $row->rev_parent_id !== null;
540 $vals['minor'] = (bool)$row->rev_minor_edit;
541 $vals['top'] = $row->page_latest == $row->rev_id;
542 }
543
544 if ( $this->fld_comment || $this->fld_parsedcomment ) {
545 if ( $row->rev_deleted & RevisionRecord::DELETED_COMMENT ) {
546 $vals['commenthidden'] = true;
547 $anyHidden = true;
548 }
549
550 $userCanView = RevisionRecord::userCanBitfield(
551 $row->rev_deleted,
552 RevisionRecord::DELETED_COMMENT, $this->getUser()
553 );
554
555 if ( $userCanView ) {
556 $comment = $this->commentStore->getComment( 'rev_comment', $row )->text;
557 if ( $this->fld_comment ) {
558 $vals['comment'] = $comment;
559 }
560
561 if ( $this->fld_parsedcomment ) {
562 $vals['parsedcomment'] = Linker::formatComment( $comment, $title );
563 }
564 }
565 }
566
567 if ( $this->fld_patrolled ) {
568 $vals['patrolled'] = $row->rc_patrolled != RecentChange::PRC_UNPATROLLED;
569 $vals['autopatrolled'] = $row->rc_patrolled == RecentChange::PRC_AUTOPATROLLED;
570 }
571
572 if ( $this->fld_size && $row->rev_len !== null ) {
573 $vals['size'] = (int)$row->rev_len;
574 }
575
576 if ( $this->fld_sizediff
577 && $row->rev_len !== null
578 && $row->rev_parent_id !== null
579 ) {
580 $parentLen = $this->parentLens[$row->rev_parent_id] ?? 0;
581 $vals['sizediff'] = (int)$row->rev_len - $parentLen;
582 }
583
584 if ( $this->fld_tags ) {
585 if ( $row->ts_tags ) {
586 $tags = explode( ',', $row->ts_tags );
587 ApiResult::setIndexedTagName( $tags, 'tag' );
588 $vals['tags'] = $tags;
589 } else {
590 $vals['tags'] = [];
591 }
592 }
593
594 if ( $anyHidden && ( $row->rev_deleted & RevisionRecord::DELETED_RESTRICTED ) ) {
595 $vals['suppressed'] = true;
596 }
597
598 return $vals;
599 }
600
601 private function continueStr( $row ) {
602 if ( $this->multiUserMode ) {
603 switch ( $this->orderBy ) {
604 case 'id':
605 return "id|$row->rev_user|$row->rev_timestamp|$row->rev_id";
606 case 'name':
607 return "name|$row->rev_user_text|$row->rev_timestamp|$row->rev_id";
608 case 'actor':
609 return "actor|$row->rev_actor|$row->rev_timestamp|$row->rev_id";
610 }
611 } else {
612 return "$row->rev_timestamp|$row->rev_id";
613 }
614 }
615
616 public function getCacheMode( $params ) {
617 // This module provides access to deleted revisions and patrol flags if
618 // the requester is logged in
619 return 'anon-public-user-private';
620 }
621
622 public function getAllowedParams() {
623 return [
624 'limit' => [
626 ApiBase::PARAM_TYPE => 'limit',
630 ],
631 'start' => [
632 ApiBase::PARAM_TYPE => 'timestamp'
633 ],
634 'end' => [
635 ApiBase::PARAM_TYPE => 'timestamp'
636 ],
637 'continue' => [
638 ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
639 ],
640 'user' => [
641 ApiBase::PARAM_TYPE => 'user',
642 UserDef::PARAM_ALLOWED_USER_TYPES => [ 'name', 'ip', 'interwiki' ],
644 ],
645 'userids' => [
646 ApiBase::PARAM_TYPE => 'integer',
648 ],
649 'userprefix' => null,
650 'dir' => [
651 ApiBase::PARAM_DFLT => 'older',
653 'newer',
654 'older'
655 ],
656 ApiBase::PARAM_HELP_MSG => 'api-help-param-direction',
657 ],
658 'namespace' => [
660 ApiBase::PARAM_TYPE => 'namespace'
661 ],
662 'prop' => [
664 ApiBase::PARAM_DFLT => 'ids|title|timestamp|comment|size|flags',
666 'ids',
667 'title',
668 'timestamp',
669 'comment',
670 'parsedcomment',
671 'size',
672 'sizediff',
673 'flags',
674 'patrolled',
675 'tags'
676 ],
678 ],
679 'show' => [
682 'minor',
683 '!minor',
684 'patrolled',
685 '!patrolled',
686 'autopatrolled',
687 '!autopatrolled',
688 'top',
689 '!top',
690 'new',
691 '!new',
692 ],
694 'apihelp-query+usercontribs-param-show',
695 $this->getConfig()->get( 'RCMaxAge' )
696 ],
697 ],
698 'tag' => null,
699 'toponly' => [
700 ApiBase::PARAM_DFLT => false,
702 ],
703 ];
704 }
705
706 protected function getExamplesMessages() {
707 return [
708 'action=query&list=usercontribs&ucuser=Example'
709 => 'apihelp-query+usercontribs-example-user',
710 'action=query&list=usercontribs&ucuserprefix=192.0.2.'
711 => 'apihelp-query+usercontribs-example-ipprefix',
712 ];
713 }
714
715 public function getHelpUrls() {
716 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Usercontribs';
717 }
718}
719
724class_alias( ApiQueryUserContribs::class, 'ApiQueryContributions' );
int $wgActorTableSchemaMigrationStage
Actor table schema migration stage, for migration from the temporary table revision_actor_temp to the...
const SCHEMA_COMPAT_READ_TEMP
Definition Defines.php:265
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
This is not intended to be a long-term part of MediaWiki; it will be deprecated and removed once acto...
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
Definition ApiBase.php:1436
const PARAM_MAX2
Definition ApiBase.php:89
const PARAM_DEPRECATED
Definition ApiBase.php:101
encodeParamName( $paramName)
This method mangles parameter name based on the prefix supplied to the constructor.
Definition ApiBase.php:742
const PARAM_MAX
Definition ApiBase.php:85
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
Definition ApiBase.php:1620
const PARAM_TYPE
Definition ApiBase.php:81
const PARAM_DFLT
Definition ApiBase.php:73
requireOnlyOneParameter( $params,... $required)
Die if none or more than one of a certain set of parameters is set and not false.
Definition ApiBase.php:901
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
Definition ApiBase.php:195
const PARAM_MIN
Definition ApiBase.php:93
const LIMIT_BIG1
Fast query, standard limit.
Definition ApiBase.php:220
getResult()
Get the result object.
Definition ApiBase.php:628
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition ApiBase.php:764
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition ApiBase.php:162
const LIMIT_BIG2
Fast query, apihighlimits limit.
Definition ApiBase.php:222
getModuleName()
Get the name of the module being executed by this instance.
Definition ApiBase.php:497
const PARAM_ISMULTI
Definition ApiBase.php:77
This is a base class for all Query modules.
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
processRow( $row, array &$data, array &$hookData)
Call the ApiQueryBaseProcessRow hook.
resetQueryParams()
Blank the internal arrays with query parameters.
addWhereIf( $value, $condition)
Same as addWhere(), but add the WHERE clauses only if a condition is met.
addWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, and an ORDER BY clause to sort in the right direction.
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)
executeGenderCacheFromResultWrapper(IResultWrapper $res, $fname=__METHOD__, $fieldPrefix='page')
Preprocess the result set to fill the GenderCache with the necessary information before using self::a...
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
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.
addWhereFld( $field, $value)
Equivalent to addWhere( [ $field => $value ] )
addWhere( $value)
Add a set of WHERE clauses to the internal array.
This query action adds a list of a specified user's contributions to the output.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getCacheMode( $params)
Get the cache mode for the data generated by this module.
getHelpUrls()
Return links to more detailed help pages about the module.
__construct(ApiQuery $query, $moduleName, CommentStore $commentStore, UserIdentityLookup $userIdentityLookup, UserNameUtils $userNameUtils, RevisionStore $revisionStore, NameTableStore $changeTagDefStore, ActorMigration $actorMigration)
getExamplesMessages()
Returns usage examples for this module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
prepareQuery(array $users, $limit)
Prepares the query and returns the limit of rows requested.
extractRowInfo( $row)
Extract fields from the database row and append them to a result array.
UserIdentityLookup $userIdentityLookup
NameTableStore $changeTagDefStore
This is the main query class.
Definition ApiQuery.php:37
static makeTagSummarySubquery( $tables)
Make the tag summary subquery based on the given tables and return it.
Handle database storage of comments such as edit summaries and log reasons.
static formatComment( $comment, $title=null, $local=false, $wikiId=null)
This function is called by all recent changes variants, by the page history, and by the user contribu...
Definition Linker.php:1372
Type definition for user types.
Definition UserDef.php:25
Page revision base class.
Service for looking up page revisions.
Exception representing a failure to look up a row from a name table.
UserNameUtils service.
Interface for objects representing user identity.
return true
Definition router.php:92