131 $this->tagFilter = $tagFilter;
132 $this->tagInvert = $tagInvert;
138 $this->revisionStore = $services->getRevisionStore();
139 $this->linkBatchFactory = $linkBatchFactory ?? $services->getLinkBatchFactory();
140 $this->watchlistManager = $watchlistManager
141 ?? $services->getWatchlistManager();
142 $this->commentFormatter = $commentFormatter ?? $services->getCommentFormatter();
143 $this->hookRunner =
new HookRunner( $hookContainer ?? $services->getHookContainer() );
145 ? $this->watchlistManager->getTitleNotificationTimestamp( $this->
getUser(), $this->
getTitle() )
147 $this->changeTagsStore = $changeTagsStore ?? $services->getChangeTagsStore();
192 if ( !$this->hookRunner->onPageHistoryPager__doBatchLookups( $this, $this->mResult ) ) {
196 # Do a link batch query
197 $batch = $this->linkBatchFactory->newLinkBatch();
200 foreach ( $this->mResult as $row ) {
201 if ( $row->rev_parent_id ) {
202 $revIds[] = (int)$row->rev_parent_id;
204 if ( $row->user_name !==
null ) {
205 $batch->add(
NS_USER, $row->user_name );
207 }
else { #
for anons or usernames of imported revisions
208 $batch->add(
NS_USER, $row->rev_user_text );
211 $this->revisions[] = $this->revisionStore->newRevisionFromRow(
213 IDBAccessObject::READ_NORMAL,
217 $this->parentLens = $this->revisionStore->getRevisionSizes( $revIds );
220 # The keys of $this->formattedComments will be the same as the keys of $this->revisions
221 $this->formattedComments = $this->commentFormatter->createRevisionBatch()
222 ->revisions( $this->revisions )
225 ->hideIfDeleted(
true )
226 ->useParentheses(
false )
229 $this->mResult->seek( 0 );
246 $this->oldIdChecked = 0;
251 $this->
getOutput()->wrapWikiMsg(
"<div class='mw-history-legend'>\n$1\n</div>",
'histlegend' );
253 $s = Html::openElement(
'form', [
255 'id' =>
'mw-history-compare'
257 $s .= Html::hidden(
'title', $this->
getTitle()->getPrefixedDBkey() ) .
"\n";
259 $this->buttons .= Html::openElement(
260 'div', [
'class' =>
'mw-history-compareselectedversions' ] );
261 $className =
'historysubmit mw-history-compareselectedversions-button cdx-button';
262 $attrs = [
'class' => $className ]
263 + Linker::tooltipAndAccesskeyAttribs(
'compareselectedversions' );
264 $this->buttons .= $this->submitButton( $this->
msg(
'compareselectedversions' )->text(),
269 if ( $this->
getAuthority()->isAllowed(
'deleterevision' ) ) {
270 $actionButtons .= $this->getRevisionButton(
271 'Revisiondelete',
'showhideselectedversions',
'mw-history-revisiondelete-button' );
273 if ( $this->showTagEditUI ) {
274 $actionButtons .= $this->getRevisionButton(
275 'EditTags',
'history-edit-tags',
'mw-history-editchangetags-button' );
277 if ( $actionButtons ) {
284 $s = Html::rawElement(
'form', [
286 'id' =>
'mw-history-revisionactions',
288 $s .= Html::hidden(
'type',
'revision', [
'form' =>
'mw-history-revisionactions' ] ) .
"\n";
290 $this->buttons .= Html::rawElement(
'div', [
'class' =>
291 'mw-history-revisionactions' ], $actionButtons );
294 if ( $this->
getAuthority()->isAllowed(
'deleterevision' ) || $this->showTagEditUI ) {
298 $this->buttons .=
'</div>';
303 $s .=
'<section id="pagehistory" class="mw-pager-body">';
361 $numRows = min( $this->mResult->numRows(), $this->mLimit );
363 $firstInList = $resultOffset === ( $this->mIsBackwards ? $numRows - 1 : 0 );
365 $nextResultOffset = $resultOffset + ( $this->mIsBackwards ? -1 : 1 );
367 $revRecord = $this->revisions[$resultOffset];
369 $previousRevRecord = $this->revisions[$nextResultOffset] ??
null;
371 $latest = $revRecord->getId() === $this->
getWikiPage()->getLatest();
372 $curlink = $this->curLink( $revRecord );
373 if ( $previousRevRecord ) {
375 $lastlink = $this->lastLink( $revRecord, $previousRevRecord );
376 } elseif ( $this->mIsBackwards && $this->mOffset !==
'' ) {
382 $lastlink = $this->lastLink( $revRecord,
null );
386 'class' =>
'mw-history-histlinks-previous',
387 ], $this->historyPage->message[
'last'] );
389 $curLastlinks = Html::rawElement(
'span', [], $curlink ) .
390 Html::rawElement(
'span', [], $lastlink );
391 $histLinks = Html::rawElement(
393 [
'class' =>
'mw-history-histlinks mw-changeslist-links' ],
397 $diffButtons = $this->diffButtons( $revRecord, $firstInList );
398 $s = $histLinks . $diffButtons;
400 $link = $this->revLink( $revRecord );
404 $canRevDelete = $this->
getAuthority()->isAllowed(
'deleterevision' );
407 if ( $canRevDelete || $this->showTagEditUI ) {
408 $this->preventClickjacking =
true;
411 if ( !$this->showTagEditUI
412 && !$revRecord->userCan( RevisionRecord::DELETED_RESTRICTED, $this->getAuthority() )
414 $del = Html::check(
'deleterevisions',
false, [
'disabled' =>
'disabled' ] );
418 'ids[' . $revRecord->getId() .
']',
false,
419 [
'form' =>
'mw-history-revisionactions' ]
423 } elseif ( $revRecord->getVisibility() && $this->getAuthority()->isAllowed(
'deletedhistory' ) ) {
425 if ( !$revRecord->userCan( RevisionRecord::DELETED_RESTRICTED, $this->getAuthority() ) ) {
426 $del = Linker::revDeleteLinkDisabled(
false );
430 'type' =>
'revision',
431 'target' => $this->
getTitle()->getPrefixedDBkey(),
432 'ids' => $revRecord->getId()
434 $del .= Linker::revDeleteLink(
436 $revRecord->isDeleted( RevisionRecord::DELETED_RESTRICTED ),
446 $dirmark = $lang->getDirMark();
450 $s .=
" <span class='history-user'>" .
451 Linker::revUserTools( $revRecord,
true,
false ) .
"</span>";
454 if ( $revRecord->isMinor() ) {
455 $s .=
' ' . ChangesList::flag(
'minor', $this->
getContext() );
458 # Sometimes rev_len isn't populated
459 if ( $revRecord->getSize() !==
null ) {
460 # Size is always public data
461 $prevSize = $this->parentLens[$row->rev_parent_id] ?? 0;
462 $sDiff = ChangesList::showCharacterDifference( $prevSize, $revRecord->getSize() );
463 $fSize = Linker::formatRevisionSize( $revRecord->getSize() );
464 $s .=
' <span class="mw-changeslist-separator"></span> ' .
"$fSize $sDiff";
467 # Include separator between character difference and following text
468 $s .=
' <span class="mw-changeslist-separator"></span> ';
470 # Text following the character difference is added just before running hooks
471 $comment = $this->formattedComments[$resultOffset];
473 if ( $comment ===
'' ) {
474 $defaultComment = $this->historyPage->message[
'changeslist-nocomment'];
475 $comment =
"<span class=\"comment mw-comment-none\">$defaultComment</span>";
479 if ( $this->notificationTimestamp && $row->rev_timestamp >= $this->notificationTimestamp ) {
480 $s .=
' <span class="updatedmarker">' . $this->historyPage->message[
'updatedmarker'] .
'</span>';
481 $classes[] =
'mw-history-line-updated';
487 $latest && $previousRevRecord,
493 if ( $pagerTools->shouldPreventClickjacking() ) {
494 $this->preventClickjacking =
true;
496 $s .= $pagerTools->toHTML();
499 [ $tagSummary, $newClasses ] = $this->tagsCache->getWithSetCallback(
500 $this->tagsCache->makeKey(
502 $this->getUser()->getName(),
511 $classes = array_merge( $classes, $newClasses );
512 if ( $tagSummary !==
'' ) {
513 $s .=
" $tagSummary";
516 $attribs = [
'data-mw-revid' => $revRecord->getId() ];
518 $this->hookRunner->onPageHistoryLineEnding( $this, $row, $s, $classes, $attribs );
519 $attribs = array_filter( $attribs,
520 [ Sanitizer::class,
'isReservedDataAttribute' ],
525 $attribs[
'class'] = implode(
' ', $classes );
528 return Html::rawElement(
'li', $attribs, $s ) .
"\n";