Replace deprecated Linker::commentBlock/revComment

Bug: T324906
Change-Id: I8cf96c3b7a03127ce1243f7a7e849b6d5a5d3dfa
This commit is contained in:
Umherirrender 2022-12-11 01:33:56 +01:00
parent 7e531cd553
commit f65e6bb488
6 changed files with 20 additions and 9 deletions

View file

@ -27,7 +27,6 @@ use CommentStore;
use DerivativeContext;
use Html;
use LogFormatter;
use MediaWiki\Linker\Linker;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\RevisionRecord;
@ -97,7 +96,7 @@ class FeedUtils {
if ( $row->rc_deleted & RevisionRecord::DELETED_COMMENT ) {
$formattedComment = wfMessage( 'rev-deleted-comment' )->escaped();
} elseif ( $formattedComment === null ) {
$formattedComment = Linker::formatComment(
$formattedComment = MediaWikiServices::getInstance()->getCommentFormatter()->format(
CommentStore::getStore()->getComment( 'rc_comment', $row )->text );
}
return self::formatDiffRow2( $titleObj,

View file

@ -21,6 +21,7 @@
* @ingroup DifferenceEngine
*/
use MediaWiki\CommentFormatter\CommentFormatter;
use MediaWiki\Content\IContentHandlerFactory;
use MediaWiki\HookContainer\HookRunner;
use MediaWiki\Linker\Linker;
@ -237,6 +238,9 @@ class DifferenceEngine extends ContextSource {
/** @var UserOptionsLookup */
private $userOptionsLookup;
/** @var CommentFormatter */
private $commentFormatter;
/** @var Message[] */
private $revisionLoadErrors = [];
@ -281,6 +285,7 @@ class DifferenceEngine extends ContextSource {
$this->hookRunner = new HookRunner( $services->getHookContainer() );
$this->wikiPageFactory = $services->getWikiPageFactory();
$this->userOptionsLookup = $services->getUserOptionsLookup();
$this->commentFormatter = $services->getCommentFormatter();
}
/**
@ -789,7 +794,8 @@ class DifferenceEngine extends ContextSource {
$ldel = $this->revisionDeleteLink( $oldRevRecord );
$oldRevisionHeader = $this->getRevisionHeader( $oldRevRecord, 'complete' );
$oldChangeTags = ChangeTags::formatSummaryRow( $this->mOldTags, 'diff', $this->getContext() );
$oldRevComment = Linker::revComment( $oldRevRecord, !$diffOnly, !$this->unhide );
$oldRevComment = $this->commentFormatter
->formatRevision( $oldRevRecord, $user, !$diffOnly, !$this->unhide );
if ( $oldRevComment === '' ) {
$defaultComment = $this->msg( 'changeslist-nocomment' )->escaped();
@ -860,7 +866,7 @@ class DifferenceEngine extends ContextSource {
$newRevisionHeader = $this->getRevisionHeader( $newRevRecord, 'complete' ) .
' ' . implode( ' ', $formattedRevisionTools );
$newChangeTags = ChangeTags::formatSummaryRow( $this->mNewTags, 'diff', $this->getContext() );
$newRevComment = Linker::revComment( $newRevRecord, !$diffOnly, !$this->unhide );
$newRevComment = $this->commentFormatter->formatRevision( $newRevRecord, $user, !$diffOnly, !$this->unhide );
if ( $newRevComment === '' ) {
$defaultComment = $this->msg( 'changeslist-nocomment' )->escaped();

View file

@ -728,7 +728,8 @@ class LogFormatter {
*/
public function getComment() {
if ( $this->canView( LogPage::DELETED_COMMENT ) ) {
$comment = Linker::commentBlock( $this->entry->getComment() );
$comment = MediaWikiServices::getInstance()->getCommentFormatter()
->formatBlock( $this->entry->getComment() );
// No hard coded spaces thanx
$element = ltrim( $comment );
if ( $this->entry->isDeleted( LogPage::DELETED_COMMENT ) ) {

View file

@ -19,6 +19,7 @@
*/
use MediaWiki\Block\DatabaseBlock;
use MediaWiki\CommentFormatter\CommentFormatter;
use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
use MediaWiki\Linker\Linker;
use MediaWiki\Linker\LinkRenderer;
@ -118,6 +119,9 @@ class Article implements Page {
*/
private $userOptionsLookup;
/** @var CommentFormatter */
private $commentFormatter;
/**
* @var RevisionRecord|null Revision to be shown
*
@ -140,6 +144,7 @@ class Article implements Page {
$this->watchlistManager = $services->getWatchlistManager();
$this->userNameUtils = $services->getUserNameUtils();
$this->userOptionsLookup = $services->getUserOptionsLookup();
$this->commentFormatter = $services->getCommentFormatter();
}
/**
@ -1626,9 +1631,10 @@ class Article implements Page {
$tdtime,
$revisionUser ? $revisionUser->getName() : ''
)
->rawParams( Linker::revComment(
->rawParams( $this->commentFormatter->formatRevision(
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable revisionRecord known to exists
$revisionRecord,
$user,
true,
true
) )

View file

@ -27,7 +27,6 @@
*/
use MediaWiki\Interwiki\ClassicInterwikiLookup;
use MediaWiki\Linker\Linker;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\Parser\ParserOutputFlags;
@ -1339,7 +1338,7 @@ class ParserTestRunner {
$replace = $opts['replace'][1];
$out = $parser->replaceSection( $wikitext, $section, $replace );
} elseif ( isset( $opts['comment'] ) ) {
$out = Linker::formatComment( $wikitext, $title, $local );
$out = MediaWikiServices::getInstance()->getCommentFormatter()->format( $wikitext, $title, $local );
} elseif ( isset( $opts['preload'] ) ) {
$out = $parser->getPreloadText( $wikitext, $title, $options );
} else {

View file

@ -289,7 +289,7 @@ class LogFormatterTest extends MediaWikiLangTestCase {
$formatter = LogFormatter::newFromEntry( $entry );
$formatter->setContext( $this->context );
$comment = ltrim( Linker::commentBlock( $entry->getComment() ) );
$comment = ltrim( $this->getServiceContainer()->getCommentFormatter()->formatBlock( $entry->getComment() ) );
$this->assertEquals( $comment, $formatter->getComment() );
}