134 $this->tagFilter = $tagFilter;
135 $this->tagInvert = $tagInvert;
141 $this->revisionStore = $services->getRevisionStore();
142 $this->linkBatchFactory = $linkBatchFactory ?? $services->getLinkBatchFactory();
143 $this->watchlistManager = $watchlistManager
144 ?? $services->getWatchlistManager();
145 $this->commentFormatter = $commentFormatter ?? $services->getCommentFormatter();
146 $this->hookRunner =
new HookRunner( $hookContainer ?? $services->getHookContainer() );
148 ? $this->watchlistManager->getTitleNotificationTimestamp( $this->
getUser(), $this->
getTitle() )
150 $this->changeTagsStore = $changeTagsStore ?? $services->getChangeTagsStore();
195 if ( !$this->hookRunner->onPageHistoryPager__doBatchLookups( $this, $this->mResult ) ) {
199 # Do a link batch query
200 $batch = $this->linkBatchFactory->newLinkBatch();
203 foreach ( $this->mResult as $row ) {
204 if ( $row->rev_parent_id ) {
205 $revIds[] = (int)$row->rev_parent_id;
207 if ( $row->user_name !==
null ) {
208 $batch->add(
NS_USER, $row->user_name );
210 }
else { #
for anons or usernames of imported revisions
211 $batch->add(
NS_USER, $row->rev_user_text );
214 $this->revisions[] = $this->revisionStore->newRevisionFromRow(
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 );
249 $this->oldIdChecked = 0;
254 $this->
getOutput()->wrapWikiMsg(
"<div class='mw-history-legend'>\n$1\n</div>",
'histlegend' );
256 $s = Html::openElement(
'form', [
258 'id' =>
'mw-history-compare'
260 $s .= Html::hidden(
'title', $this->
getTitle()->getPrefixedDBkey() ) .
"\n";
262 $this->buttons .= Html::openElement(
263 'div', [
'class' =>
'mw-history-compareselectedversions' ] );
264 $className =
'historysubmit mw-history-compareselectedversions-button cdx-button';
265 $attrs = [
'class' => $className ]
266 + Linker::tooltipAndAccesskeyAttribs(
'compareselectedversions' );
267 $this->buttons .= $this->submitButton( $this->
msg(
'compareselectedversions' )->text(),
272 if ( $this->
getAuthority()->isAllowed(
'deleterevision' ) ) {
273 $actionButtons .= $this->getRevisionButton(
274 'Revisiondelete',
'showhideselectedversions',
'mw-history-revisiondelete-button' );
276 if ( $this->showTagEditUI ) {
277 $actionButtons .= $this->getRevisionButton(
278 'EditTags',
'history-edit-tags',
'mw-history-editchangetags-button' );
280 if ( $actionButtons ) {
287 $s = Html::rawElement(
'form', [
289 'id' =>
'mw-history-revisionactions',
291 $s .= Html::hidden(
'type',
'revision', [
'form' =>
'mw-history-revisionactions' ] ) .
"\n";
293 $this->buttons .= Html::rawElement(
'div', [
'class' =>
294 'mw-history-revisionactions' ], $actionButtons );
297 if ( $this->
getAuthority()->isAllowed(
'deleterevision' ) || $this->showTagEditUI ) {
301 $this->buttons .=
'</div>';
306 $s .=
'<section id="pagehistory" class="mw-pager-body">';
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 ),
449 $dirmark = $lang->getDirMark();
453 $s .=
" <span class='history-user'>" .
454 Linker::revUserTools( $revRecord,
true,
false ) .
"</span>";
457 if ( $revRecord->isMinor() ) {
458 $s .=
' ' . ChangesList::flag(
'minor', $this->
getContext() );
461 # Sometimes rev_len isn't populated
462 if ( $revRecord->getSize() !==
null ) {
463 # Size is always public data
464 $prevSize = $this->parentLens[$row->rev_parent_id] ?? 0;
465 $sDiff = ChangesList::showCharacterDifference( $prevSize, $revRecord->getSize() );
466 $fSize = Linker::formatRevisionSize( $revRecord->getSize() );
467 $s .=
' <span class="mw-changeslist-separator"></span> ' .
"$fSize $sDiff";
470 # Include separator between character difference and following text
471 $s .=
' <span class="mw-changeslist-separator"></span> ';
473 # Text following the character difference is added just before running hooks
474 $comment = $this->formattedComments[$resultOffset];
476 if ( $comment ===
'' ) {
477 $defaultComment = $this->historyPage->message[
'changeslist-nocomment'];
478 $comment =
"<span class=\"comment mw-comment-none\">$defaultComment</span>";
482 if ( $this->notificationTimestamp && $row->rev_timestamp >= $this->notificationTimestamp ) {
483 $s .=
' <span class="updatedmarker">' . $this->historyPage->message[
'updatedmarker'] .
'</span>';
484 $classes[] =
'mw-history-line-updated';
490 $latest && $previousRevRecord,
496 if ( $pagerTools->shouldPreventClickjacking() ) {
497 $this->preventClickjacking =
true;
499 $s .= $pagerTools->toHTML();
502 [ $tagSummary, $newClasses ] = $this->tagsCache->getWithSetCallback(
503 $this->tagsCache->makeKey(
505 $this->getUser()->getName(),
514 $classes = array_merge( $classes, $newClasses );
515 if ( $tagSummary !==
'' ) {
516 $s .=
" $tagSummary";
519 $attribs = [
'data-mw-revid' => $revRecord->getId() ];
521 $this->hookRunner->onPageHistoryLineEnding( $this, $row, $s, $classes, $attribs );
522 $attribs = array_filter( $attribs,
523 [ Sanitizer::class,
'isReservedDataAttribute' ],
528 $attribs[
'class'] = implode(
' ', $classes );
531 return Html::rawElement(
'li', $attribs, $s ) .
"\n";