aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--includes/Feed/FeedUtils.php3
-rw-r--r--includes/diff/DifferenceEngine.php10
-rw-r--r--includes/logging/LogFormatter.php3
-rw-r--r--includes/page/Article.php8
-rw-r--r--tests/parser/ParserTestRunner.php3
-rw-r--r--tests/phpunit/includes/logging/LogFormatterTest.php2
6 files changed, 20 insertions, 9 deletions
diff --git a/includes/Feed/FeedUtils.php b/includes/Feed/FeedUtils.php
index 551cebc9b46c..c0860e08f56e 100644
--- a/includes/Feed/FeedUtils.php
+++ b/includes/Feed/FeedUtils.php
@@ -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,
diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php
index 60c368902323..06196a769280 100644
--- a/includes/diff/DifferenceEngine.php
+++ b/includes/diff/DifferenceEngine.php
@@ -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();
diff --git a/includes/logging/LogFormatter.php b/includes/logging/LogFormatter.php
index e305f064fff5..bee407957939 100644
--- a/includes/logging/LogFormatter.php
+++ b/includes/logging/LogFormatter.php
@@ -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 ) ) {
diff --git a/includes/page/Article.php b/includes/page/Article.php
index c188b0821ee6..1710a80c0fe0 100644
--- a/includes/page/Article.php
+++ b/includes/page/Article.php
@@ -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
) )
diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php
index 974d58ae4971..04f87953914b 100644
--- a/tests/parser/ParserTestRunner.php
+++ b/tests/parser/ParserTestRunner.php
@@ -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 {
diff --git a/tests/phpunit/includes/logging/LogFormatterTest.php b/tests/phpunit/includes/logging/LogFormatterTest.php
index ac3bb290ceb0..1fb64f2f15be 100644
--- a/tests/phpunit/includes/logging/LogFormatterTest.php
+++ b/tests/phpunit/includes/logging/LogFormatterTest.php
@@ -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() );
}