63 foreach ( $msgs as $msg ) {
64 $this->messages[$msg] = $this->
msg( $msg )->escaped();
68 $this->contribs = isset(
$options[
'contribs'] ) ?
$options[
'contribs'] :
'users';
69 $this->
namespace = isset(
$options['namespace'] ) ?
$options['namespace'] : '';
70 $this->tagFilter = isset( $options['tagfilter'] ) ?
$options['tagfilter'] : false;
71 $this->nsInvert = isset( $options['nsInvert'] ) ?
$options['nsInvert'] : false;
72 $this->associated = isset( $options['associated'] ) ?
$options['associated'] : false;
74 $this->deletedOnly = !empty( $options['deletedOnly'] );
75 $this->topOnly = !empty( $options['topOnly'] );
76 $this->newOnly = !empty( $options['newOnly'] );
77 $this->hideMinor = !empty( $options['hideMinor'] );
82 if ( $options['start'] ) {
83 $startTimestamp =
$options[
'start'] .
' 00:00:00';
86 $endTimestamp =
$options[
'end'] .
' 23:59:59';
99 $this->templateParser =
new TemplateParser();
103 $query = parent::getDefaultQuery();
143 $data = [ $this->mDb->select(
147 'ContribsPager::reallyDoQuery',
148 [ &$data, $this, $offset, $limit, $descending ]
154 foreach ( $data as
$query ) {
155 foreach (
$query as $i => $row ) {
169 $result = array_slice( $result, 0, $limit );
172 $result = array_values( $result );
178 list(
$tables, $index, $userCond, $join_cond ) = $this->getUserCond();
180 $user = $this->getUser();
181 $conds = array_merge( $userCond, $this->getNamespaceCond() );
184 if ( !$user->isAllowed(
'deletedhistory' ) ) {
186 } elseif ( !$user->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
191 # Don't include orphaned revisions
193 # Get the current user name for accounts
198 $options[
'USE INDEX'] = [
'revision' => $index ];
203 'fields' => array_merge(
206 [
'page_namespace',
'page_title',
'page_is_new',
207 'page_latest',
'page_is_redirect',
'page_len' ]
211 'join_conds' => $join_cond
216 if ( self::isQueryableRange( $this->target ) ) {
217 $queryInfo[
'fields'][] =
'ipc_rev_timestamp';
221 $queryInfo[
'tables'],
222 $queryInfo[
'fields'],
224 $queryInfo[
'join_conds'],
225 $queryInfo[
'options'],
231 Hooks::run(
'ContribsPager::getQueryInfo', [ &$pager, &$queryInfo ] );
239 $tables = [
'revision',
'page',
'user' ];
241 if ( $this->contribs ==
'newbie' ) {
242 $max = $this->mDb->selectField(
'user',
'max(user_id)',
false, __METHOD__ );
243 $condition[] =
'rev_user >' . (int)( $max - $max / 100 );
244 # ignore local groups with the bot right
245 # @todo FIXME: Global groups may have 'bot' rights
246 $groupsWithBotPermission = User::getGroupsWithPermission(
'bot' );
247 if ( count( $groupsWithBotPermission ) ) {
249 $condition[] =
'ug_group IS NULL';
250 $join_conds[
'user_groups'] = [
252 'ug_user = rev_user',
253 'ug_group' => $groupsWithBotPermission,
254 'ug_expiry IS NULL OR ug_expiry >= ' .
255 $this->mDb->addQuotes( $this->mDb->timestamp() )
262 $condition[] =
'rev_timestamp > ' .
263 $this->mDb->addQuotes( $this->mDb->timestamp(
wfTimestamp() - 30 * 24 * 60 * 60 ) );
265 $uid = User::idFromName( $this->target );
267 $condition[
'rev_user'] = $uid;
268 $index =
'user_timestamp';
270 $ipRangeConds = $this->getIpRangeConds( $this->mDb, $this->target );
272 if ( $ipRangeConds ) {
274 $join_conds[
'ip_changes'] = [
275 'LEFT JOIN', [
'ipc_rev_id = rev_id' ]
277 $condition[] = $ipRangeConds;
279 $condition[
'rev_user_text'] = $this->target;
280 $index =
'usertext_timestamp';
285 if ( $this->deletedOnly ) {
286 $condition[] =
'rev_deleted != 0';
289 if ( $this->topOnly ) {
290 $condition[] =
'rev_id = page_latest';
293 if ( $this->newOnly ) {
294 $condition[] =
'rev_parent_id = 0';
297 if ( $this->hideMinor ) {
298 $condition[] =
'rev_minor_edit = 0';
301 return [
$tables, $index, $condition, $join_conds ];
305 if ( $this->
namespace !==
'' ) {
306 $selectedNS = $this->mDb->addQuotes( $this->
namespace );
307 $eq_op = $this->nsInvert ?
'!=' :
'=';
308 $bool_op = $this->nsInvert ?
'AND' :
'OR';
310 if ( !$this->associated ) {
311 return [
"page_namespace $eq_op $selectedNS" ];
314 $associatedNS = $this->mDb->addQuotes(
315 MWNamespace::getAssociated( $this->
namespace )
319 "page_namespace $eq_op $selectedNS " .
321 " page_namespace $eq_op $associatedNS"
336 if ( !$this->isQueryableRange( $ip ) ) {
340 list( $start, $end ) = IP::parseRange( $ip );
342 return 'ipc_hex BETWEEN ' . $db->addQuotes( $start ) .
' AND ' . $db->addQuotes( $end );
353 $limits = $this->getConfig()->get(
'RangeContributionsCIDRLimit' );
355 $bits = IP::parseCIDR( $ipRange )[1];
357 ( $bits ===
false ) ||
358 ( IP::isIPv4( $ipRange ) && $bits < $limits[
'IPv4'] ) ||
359 ( IP::isIPv6( $ipRange ) && $bits < $limits[
'IPv6'] )
374 if ( $this->isQueryableRange( $this->target ) ) {
375 return 'ipc_rev_timestamp';
377 return 'rev_timestamp';
382 # Do a link batch query
383 $this->mResult->seek( 0 );
385 $this->mParentLens = [];
387 $isIpRange = $this->isQueryableRange( $this->target );
388 # Give some pointers to make (last) links
389 foreach ( $this->mResult as $row ) {
390 if ( isset( $row->rev_parent_id ) && $row->rev_parent_id ) {
391 $parentRevIds[] = $row->rev_parent_id;
393 if ( isset( $row->rev_id ) ) {
394 $this->mParentLens[$row->rev_id] = $row->rev_len;
395 if ( $this->contribs ===
'newbie' ) {
396 $batch->add( NS_USER, $row->user_name );
398 } elseif ( $isIpRange ) {
402 $batch->add( $row->page_namespace, $row->page_title );
405 # Fetch rev_len for revisions not already scanned above
408 array_diff( $parentRevIds, array_keys( $this->mParentLens ) )
411 $this->mResult->seek( 0 );
418 return "<ul class=\"mw-contributions-list\">\n";
445 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
454 MediaWiki\suppressWarnings();
457 $validRevision = (bool)
$rev->getId();
458 }
catch ( Exception
$e ) {
459 $validRevision =
false;
461 MediaWiki\restoreWarnings();
463 if ( $validRevision ) {
466 $page = Title::newFromRow( $row );
469 $page->getPrefixedText(),
470 [
'class' =>
'mw-contributions-title' ],
471 $page->isRedirect() ? [
'redirect' =>
'no' ] : []
473 # Mark current revisions
475 $user = $this->getUser();
477 if ( $row->rev_id === $row->page_latest ) {
478 $topmarktext .=
'<span class="mw-uctop">' . $this->messages[
'uctop'] .
'</span>';
479 $classes[] =
'mw-contributions-current';
481 if ( !$row->page_is_new && $page->quickUserCan(
'rollback', $user )
482 && $page->quickUserCan(
'edit', $user )
484 $this->preventClickjacking();
488 # Is there a visible previous revision?
492 new HtmlArmor( $this->messages[
'diff'] ),
493 [
'class' =>
'mw-changeslist-diff' ],
496 'oldid' => $row->rev_id
500 $difftext = $this->messages[
'diff'];
504 new HtmlArmor( $this->messages[
'hist'] ),
505 [
'class' =>
'mw-changeslist-history' ],
506 [
'action' =>
'history' ]
509 if ( $row->rev_parent_id ===
null ) {
513 $chardiff =
' <span class="mw-changeslist-separator">. .</span> ';
515 $chardiff .=
' <span class="mw-changeslist-separator">. .</span> ';
518 if ( isset( $this->mParentLens[$row->rev_parent_id] ) ) {
519 $parentLen = $this->mParentLens[$row->rev_parent_id];
522 $chardiff =
' <span class="mw-changeslist-separator">. .</span> ';
528 $chardiff .=
' <span class="mw-changeslist-separator">. .</span> ';
531 $lang = $this->getLanguage();
533 $date =
$lang->userTimeAndDate( $row->rev_timestamp, $user );
538 [
'class' =>
'mw-changeslist-date' ],
539 [
'oldid' => intval( $row->rev_id ) ]
542 $d = htmlspecialchars( $date );
545 $d =
'<span class="history-deleted">' . $d .
'</span>';
548 # Show user names for /newbies as there may be different users.
549 # Note that only unprivileged users have rows with hidden user names excluded.
550 # When querying for an IP range, we want to always show user and user talk links.
553 || $this->isQueryableRange( $this->target ) ) {
554 $userlink =
' . . ' .
$lang->getDirMark()
556 $userlink .=
' ' . $this->msg(
'parentheses' )->rawParams(
561 if (
$rev->getParentId() === 0 ) {
565 if (
$rev->isMinor() ) {
574 $diffHistLinks = $this->msg(
'parentheses' )
575 ->rawParams( $difftext . $this->messages[
'pipe-separator'] . $histlink )
584 $classes = array_merge( $classes, $newClasses );
586 Hooks::run(
'SpecialContributions::formatRow::flags', [ $this->
getContext(), $row, &
$flags ] );
591 'diffHistLinks' => $diffHistLinks,
592 'charDifference' => $chardiff,
594 'articleLink' =>
$link,
595 'userlink' => $userlink,
596 'logText' => $comment,
597 'topmarktext' => $topmarktext,
598 'tagSummary' => $tagSummary,
601 # Denote if username is redacted for this edit
603 $templateParams[
'rev-deleted-user-contribs'] =
604 $this->msg(
'rev-deleted-user-contribs' )->escaped();
607 $ret = $this->templateParser->processTemplate(
608 'SpecialContributionsLine',
614 Hooks::run(
'ContributionsLineEnding', [ $this, &
$ret, $row, &$classes, &
$attribs ] );
620 if ( $classes === [] &&
$attribs === [] &&
$ret ===
'' ) {
621 wfDebug(
"Dropping Special:Contribution row that could not be formatted\n" );
622 return "<!-- Could not format Special:Contribution row. -->\n";
636 if ( $this->
namespace || $this->deletedOnly ) {
638 return 'contributions page filtered for namespace or RevisionDeleted edits';
640 return 'contributions page unfiltered';
645 $this->preventClickjacking =
true;
652 return $this->preventClickjacking;
662 $start = isset( $opts[
'start'] ) ? $opts[
'start'] :
'';
663 $end = isset( $opts[
'end'] ) ? $opts[
'end'] :
'';
664 $year = isset( $opts[
'year'] ) ? $opts[
'year'] :
'';
665 $month = isset( $opts[
'month'] ) ? $opts[
'month'] :
'';
667 if ( $start !==
'' && $end !==
'' && $start > $end ) {
674 if ( $year !==
'' || $month !==
'' ) {
679 $legacyDateTime =
new DateTime( $legacyTimestamp->getTimestamp( TS_ISO_8601 ) );
680 $legacyDateTime = $legacyDateTime->modify(
'-1 day' );
685 $end = $legacyDateTime->format(
'Y-m-d' );
688 $opts[
'start'] = $start;
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfArrayFilterByKey(array $arr, callable $callback)
Like array_filter with ARRAY_FILTER_USE_KEY, but works pre-5.6.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
static showCharacterDifference( $old, $new, IContextSource $context=null)
Show formatted char difference.
static flag( $flag, IContextSource $context=null)
Make an "<abbr>" element for a given change flag.
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
Marks HTML that shouldn't be escaped.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
static generateRollback( $rev, IContextSource $context=null, $options=[ 'verify'])
Generate a rollback link for a given revision.
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
static revComment(Revision $rev, $local=false, $isPublic=false)
Wrap and format the given revision's comment block, if the current user is allowed to view it.
static formatRevisionSize( $size)
static userTalkLink( $userId, $userText)
static getRevDeleteLink(User $user, Revision $rev, Title $title)
Get a revision-deletion link, or disabled link, or nothing, depending on user permissions & the setti...
static userJoinCond()
Return the value of a select() JOIN conds array for the user table.
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
static selectUserFields()
Return the list of user fields that should be selected from user table.
static pageJoinCond()
Return the value of a select() page conds array for the page table.
static getParentLengths( $db, array $revIds)
Do a batched query to get the parent revision lengths.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
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 & $options
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
it s the revision text itself In either if gzip is the revision text is gzipped $flags
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
usually copyright or history_copyright This message must be in HTML not wikitext & $link
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 just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
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
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 just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form before processing starts Return false to skip default processing and return $ret $linkRenderer
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
returning false will NOT prevent logging $e
Interface for objects which can provide a MediaWiki context on request.
if(!isset( $args[0])) $lang