129 $this->tagFilter = $tagFilter;
130 $this->tagInvert = $tagInvert;
136 $this->revisionStore = $services->getRevisionStore();
137 $this->linkBatchFactory = $linkBatchFactory ?? $services->getLinkBatchFactory();
138 $this->watchlistManager = $watchlistManager
139 ?? $services->getWatchlistManager();
140 $this->commentFormatter = $commentFormatter ?? $services->getCommentFormatter();
141 $this->hookRunner =
new HookRunner( $hookContainer ?? $services->getHookContainer() );
143 ? $this->watchlistManager->getTitleNotificationTimestamp( $this->
getUser(), $this->
getTitle() )
145 $this->changeTagsStore = $changeTagsStore ?? $services->getChangeTagsStore();
190 if ( !$this->hookRunner->onPageHistoryPager__doBatchLookups( $this, $this->mResult ) ) {
194 # Do a link batch query
195 $batch = $this->linkBatchFactory->newLinkBatch();
198 foreach ( $this->mResult as $row ) {
199 if ( $row->rev_parent_id ) {
200 $revIds[] = (int)$row->rev_parent_id;
202 if ( $row->user_name !==
null ) {
203 $batch->add(
NS_USER, $row->user_name );
205 }
else { #
for anons or usernames of imported revisions
206 $batch->add(
NS_USER, $row->rev_user_text );
209 $this->revisions[] = $this->revisionStore->newRevisionFromRow(
211 IDBAccessObject::READ_NORMAL,
215 $this->parentLens = $this->revisionStore->getRevisionSizes( $revIds );
218 # The keys of $this->formattedComments will be the same as the keys of $this->revisions
219 $this->formattedComments = $this->commentFormatter->createRevisionBatch()
220 ->revisions( $this->revisions )
223 ->hideIfDeleted(
true )
224 ->useParentheses(
false )
227 $this->mResult->seek( 0 );
244 $this->oldIdChecked = 0;
249 $this->
getOutput()->wrapWikiMsg(
"<div class='mw-history-legend'>\n$1\n</div>",
'histlegend' );
251 $s = Html::openElement(
'form', [
253 'id' =>
'mw-history-compare'
255 $s .= Html::hidden(
'title', $this->
getTitle()->getPrefixedDBkey() ) .
"\n";
257 $this->buttons .= Html::openElement(
258 'div', [
'class' =>
'mw-history-compareselectedversions' ] );
259 $className =
'historysubmit mw-history-compareselectedversions-button cdx-button';
260 $attrs = [
'class' => $className ]
261 + Linker::tooltipAndAccesskeyAttribs(
'compareselectedversions' );
262 $this->buttons .= $this->submitButton( $this->
msg(
'compareselectedversions' )->text(),
267 if ( $this->
getAuthority()->isAllowed(
'deleterevision' ) ) {
268 $actionButtons .= $this->getRevisionButton(
269 'Revisiondelete',
'showhideselectedversions',
'mw-history-revisiondelete-button' );
271 if ( $this->showTagEditUI ) {
272 $actionButtons .= $this->getRevisionButton(
273 'EditTags',
'history-edit-tags',
'mw-history-editchangetags-button' );
275 if ( $actionButtons ) {
282 $s = Html::rawElement(
'form', [
284 'id' =>
'mw-history-revisionactions',
286 $s .= Html::hidden(
'type',
'revision', [
'form' =>
'mw-history-revisionactions' ] ) .
"\n";
288 $this->buttons .= Html::rawElement(
'div', [
'class' =>
289 'mw-history-revisionactions' ], $actionButtons );
292 if ( $this->
getAuthority()->isAllowed(
'deleterevision' ) || $this->showTagEditUI ) {
296 $this->buttons .=
'</div>';
301 $s .=
'<section id="pagehistory" class="mw-pager-body">';
359 $numRows = min( $this->mResult->numRows(), $this->mLimit );
361 $firstInList = $resultOffset === ( $this->mIsBackwards ? $numRows - 1 : 0 );
363 $nextResultOffset = $resultOffset + ( $this->mIsBackwards ? -1 : 1 );
365 $revRecord = $this->revisions[$resultOffset];
367 $previousRevRecord = $this->revisions[$nextResultOffset] ??
null;
369 $latest = $revRecord->getId() === $this->
getWikiPage()->getLatest();
370 $curlink = $this->curLink( $revRecord );
371 if ( $previousRevRecord ) {
373 $lastlink = $this->lastLink( $revRecord, $previousRevRecord );
374 } elseif ( $this->mIsBackwards && $this->mOffset !==
'' ) {
380 $lastlink = $this->lastLink( $revRecord,
null );
384 'class' =>
'mw-history-histlinks-previous',
385 ], $this->historyPage->message[
'last'] );
387 $curLastlinks = Html::rawElement(
'span', [], $curlink ) .
388 Html::rawElement(
'span', [], $lastlink );
389 $histLinks = Html::rawElement(
391 [
'class' =>
'mw-history-histlinks mw-changeslist-links' ],
395 $diffButtons = $this->diffButtons( $revRecord, $firstInList );
396 $s = $histLinks . $diffButtons;
398 $link = $this->revLink( $revRecord );
402 $canRevDelete = $this->
getAuthority()->isAllowed(
'deleterevision' );
405 if ( $canRevDelete || $this->showTagEditUI ) {
406 $this->preventClickjacking =
true;
409 if ( !$this->showTagEditUI
410 && !$revRecord->userCan( RevisionRecord::DELETED_RESTRICTED, $this->getAuthority() )
412 $del = Html::check(
'deleterevisions',
false, [
'disabled' =>
'disabled' ] );
416 'ids[' . $revRecord->getId() .
']',
false,
417 [
'form' =>
'mw-history-revisionactions' ]
421 } elseif ( $revRecord->getVisibility() && $this->getAuthority()->isAllowed(
'deletedhistory' ) ) {
423 if ( !$revRecord->userCan( RevisionRecord::DELETED_RESTRICTED, $this->getAuthority() ) ) {
424 $del = Linker::revDeleteLinkDisabled(
false );
428 'type' =>
'revision',
429 'target' => $this->
getTitle()->getPrefixedDBkey(),
430 'ids' => $revRecord->getId()
432 $del .= Linker::revDeleteLink(
434 $revRecord->isDeleted( RevisionRecord::DELETED_RESTRICTED ),
444 $dirmark = $lang->getDirMark();
448 $s .=
" <span class='history-user'>" .
449 Linker::revUserTools( $revRecord,
true,
false ) .
"</span>";
452 if ( $revRecord->isMinor() ) {
453 $s .=
' ' . ChangesList::flag(
'minor', $this->
getContext() );
456 # Sometimes rev_len isn't populated
457 if ( $revRecord->getSize() !==
null ) {
458 # Size is always public data
459 $prevSize = $this->parentLens[$row->rev_parent_id] ?? 0;
460 $sDiff = ChangesList::showCharacterDifference( $prevSize, $revRecord->getSize() );
461 $fSize = Linker::formatRevisionSize( $revRecord->getSize() );
462 $s .=
' <span class="mw-changeslist-separator"></span> ' .
"$fSize $sDiff";
465 # Include separator between character difference and following text
466 $s .=
' <span class="mw-changeslist-separator"></span> ';
468 # Text following the character difference is added just before running hooks
469 $comment = $this->formattedComments[$resultOffset];
471 if ( $comment ===
'' ) {
472 $defaultComment = $this->historyPage->message[
'changeslist-nocomment'];
473 $comment =
"<span class=\"comment mw-comment-none\">$defaultComment</span>";
477 if ( $this->notificationTimestamp && $row->rev_timestamp >= $this->notificationTimestamp ) {
478 $s .=
' <span class="updatedmarker">' . $this->historyPage->message[
'updatedmarker'] .
'</span>';
479 $classes[] =
'mw-history-line-updated';
485 $latest && $previousRevRecord,
491 if ( $pagerTools->shouldPreventClickjacking() ) {
492 $this->preventClickjacking =
true;
494 $s .= $pagerTools->toHTML();
497 [ $tagSummary, $newClasses ] = $this->tagsCache->getWithSetCallback(
498 $this->tagsCache->makeKey(
500 $this->getUser()->getName(),
509 $classes = array_merge( $classes, $newClasses );
510 if ( $tagSummary !==
'' ) {
511 $s .=
" $tagSummary";
514 $attribs = [
'data-mw-revid' => $revRecord->getId() ];
516 $this->hookRunner->onPageHistoryLineEnding( $this, $row, $s, $classes, $attribs );
517 $attribs = array_filter( $attribs,
518 [ Sanitizer::class,
'isReservedDataAttribute' ],
523 $attribs[
'class'] = implode(
' ', $classes );
526 return Html::rawElement(
'li', $attribs, $s ) .
"\n";