135 $this->tagFilter = $tagFilter;
136 $this->tagInvert = $tagInvert;
139 $this->showTagEditUI = ChangeTags::showTagEditingUI( $this->
getAuthority() );
142 $this->revisionStore = $services->getRevisionStore();
143 $this->linkBatchFactory = $linkBatchFactory ?? $services->getLinkBatchFactory();
144 $this->watchlistManager = $watchlistManager
145 ?? $services->getWatchlistManager();
146 $this->commentFormatter = $commentFormatter ?? $services->getCommentFormatter();
147 $this->hookRunner =
new HookRunner( $hookContainer ?? $services->getHookContainer() );
149 ? $this->watchlistManager->getTitleNotificationTimestamp( $this->
getUser(), $this->
getTitle() )
151 $this->changeTagsStore = $changeTagsStore ?? $services->getChangeTagsStore();
196 if ( !$this->hookRunner->onPageHistoryPager__doBatchLookups( $this, $this->mResult ) ) {
200 # Do a link batch query
201 $batch = $this->linkBatchFactory->newLinkBatch();
204 foreach ( $this->mResult as $row ) {
205 if ( $row->rev_parent_id ) {
206 $revIds[] = (int)$row->rev_parent_id;
208 if ( $row->user_name !==
null ) {
210 }
else { #
for anons or usernames of imported revisions
211 $batch->add(
NS_USER, $row->rev_user_text );
214 $this->revisions[] = $this->revisionStore->newRevisionFromRow(
216 IDBAccessObject::READ_NORMAL,
220 $this->parentLens = $this->revisionStore->getRevisionSizes( $revIds );
223 # The keys of $this->formattedComments will be the same as the keys of $this->revisions
224 $this->formattedComments = $this->commentFormatter->createRevisionBatch()
225 ->revisions( $this->revisions )
228 ->hideIfDeleted(
true )
229 ->useParentheses(
false )
232 $this->mResult->seek( 0 );
363 $resultOffset = $this->getResultOffset();
364 $numRows = min( $this->mResult->numRows(), $this->mLimit );
366 $firstInList = $resultOffset === ( $this->mIsBackwards ? $numRows - 1 : 0 );
368 $nextResultOffset = $resultOffset + ( $this->mIsBackwards ? -1 : 1 );
370 $revRecord = $this->revisions[$resultOffset];
372 $previousRevRecord = $this->revisions[$nextResultOffset] ??
null;
374 $latest = $revRecord->getId() === $this->getWikiPage()->getLatest();
375 $curlink = $this->curLink( $revRecord );
376 if ( $previousRevRecord ) {
378 $lastlink = $this->lastLink( $revRecord, $previousRevRecord );
379 } elseif ( $this->mIsBackwards && $this->mOffset !==
'' ) {
385 $lastlink = $this->lastLink( $revRecord,
null );
389 'class' =>
'mw-history-histlinks-previous',
390 ], $this->historyPage->message[
'last'] );
392 $curLastlinks = Html::rawElement(
'span', [], $curlink ) .
393 Html::rawElement(
'span', [], $lastlink );
394 $histLinks = Html::rawElement(
396 [
'class' =>
'mw-history-histlinks mw-changeslist-links' ],
400 $diffButtons = $this->diffButtons( $revRecord, $firstInList );
401 $s = $histLinks . $diffButtons;
403 $link = $this->revLink( $revRecord );
407 $canRevDelete = $this->getAuthority()->isAllowed(
'deleterevision' );
410 if ( $canRevDelete || $this->showTagEditUI ) {
411 $this->preventClickjacking =
true;
414 if ( !$this->showTagEditUI
415 && !$revRecord->userCan( RevisionRecord::DELETED_RESTRICTED, $this->getAuthority() )
417 $del = Html::check(
'deleterevisions',
false, [
'disabled' =>
'disabled' ] );
421 'ids[' . $revRecord->getId() .
']',
false,
422 [
'form' =>
'mw-history-revisionactions' ]
426 } elseif ( $revRecord->getVisibility() && $this->getAuthority()->isAllowed(
'deletedhistory' ) ) {
428 if ( !$revRecord->userCan( RevisionRecord::DELETED_RESTRICTED, $this->getAuthority() ) ) {
429 $del = Linker::revDeleteLinkDisabled(
false );
433 'type' =>
'revision',
434 'target' => $this->
getTitle()->getPrefixedDBkey(),
435 'ids' => $revRecord->getId()
437 $del .= Linker::revDeleteLink(
439 $revRecord->isDeleted( RevisionRecord::DELETED_RESTRICTED ),
448 $lang = $this->getLanguage();
449 $s .=
' ' . Html::rawElement(
'bdi', [
'dir' => $lang->getDir() ], $link );
450 $s .=
" <span class='history-user'>" .
451 Linker::revUserTools( $revRecord,
true,
false ) .
"</span>";
453 if ( $revRecord->isMinor() ) {
454 $s .=
' ' . ChangesList::flag(
'minor', $this->getContext() );
457 # Sometimes rev_len isn't populated
458 if ( $revRecord->getSize() !==
null ) {
459 # Size is always public data
460 $prevSize = $this->parentLens[$row->rev_parent_id] ?? 0;
461 $sDiff = ChangesList::showCharacterDifference( $prevSize, $revRecord->getSize() );
462 $fSize = Linker::formatRevisionSize( $revRecord->getSize() );
463 $s .=
' <span class="mw-changeslist-separator"></span> ' .
"$fSize $sDiff";
466 # Include separator between character difference and following text
467 $s .=
' <span class="mw-changeslist-separator"></span> ';
469 # Text following the character difference is added just before running hooks
470 $comment = $this->formattedComments[$resultOffset];
472 if ( $comment ===
'' ) {
473 $defaultComment = $this->historyPage->message[
'changeslist-nocomment'];
474 $comment =
"<span class=\"comment mw-comment-none\">$defaultComment</span>";
478 if ( $this->notificationTimestamp && $row->rev_timestamp >= $this->notificationTimestamp ) {
479 $s .=
' <span class="updatedmarker">' . $this->historyPage->message[
'updatedmarker'] .
'</span>';
480 $classes[] =
'mw-history-line-updated';
486 $latest && $previousRevRecord,
490 $this->getLinkRenderer()
492 if ( $pagerTools->shouldPreventClickjacking() ) {
493 $this->preventClickjacking =
true;
495 $s .= $pagerTools->toHTML();
498 [ $tagSummary, $newClasses ] = $this->tagsCache->getWithSetCallback(
499 $this->tagsCache->makeKey(
501 $this->getUser()->getName(),
504 fn () => ChangeTags::formatSummaryRow(
510 $classes = array_merge( $classes, $newClasses );
511 if ( $tagSummary !==
'' ) {
512 $s .=
" $tagSummary";
515 $attribs = [
'data-mw-revid' => $revRecord->getId() ];
517 $this->hookRunner->onPageHistoryLineEnding( $this, $row, $s, $classes, $attribs );
518 $attribs = array_filter( $attribs,
519 [ Sanitizer::class,
'isReservedDataAttribute' ],
522 $attribs[
'class'] = $classes;
524 return Html::rawElement(
'li', $attribs, $s ) .
"\n";