Replace deprecated LogFormatter::newFromRow/newFromEntry

Change-Id: I453ce3148a46fcb9cc5c685cee92274e0cb4f98a
This commit is contained in:
Umherirrender 2024-07-12 23:46:41 +02:00
parent 674cd4ea18
commit 07db7102cc
26 changed files with 107 additions and 45 deletions

View file

@ -23,7 +23,6 @@
namespace MediaWiki\Feed;
use LogFormatter;
use MediaWiki\Content\TextContent;
use MediaWiki\Context\DerivativeContext;
use MediaWiki\Context\RequestContext;
@ -89,7 +88,8 @@ class FeedUtils {
$actiontext = '';
if ( $row->rc_type == RC_LOG ) {
$rcRow = (array)$row; // newFromRow() only accepts arrays for RC rows
$actiontext = LogFormatter::newFromRow( $rcRow )->getActionText();
$actiontext = MediaWikiServices::getInstance()->getLogFormatterFactory()
->newFromRow( $rcRow )->getActionText();
}
if ( $row->rc_deleted & RevisionRecord::DELETED_COMMENT ) {
$formattedComment = wfMessage( 'rev-deleted-comment' )->escaped();

View file

@ -2706,7 +2706,8 @@ return [
$services->getArchivedRevisionLookup(),
$services->getRestrictionStore(),
$services->getLinkTargetLookup(),
$services->getRedirectStore()
$services->getRedirectStore(),
$services->getLogFormatterFactory()
);
},

View file

@ -386,6 +386,7 @@ class ApiQuery extends ApiBase {
'RowCommentFormatter',
'ChangeTagDefStore',
'UserNameUtils',
'LogFormatterFactory',
],
],
'pageswithprop' => [
@ -427,6 +428,7 @@ class ApiQuery extends ApiBase {
'SlotRoleRegistry',
'UserNameUtils',
'TempUserConfig',
'LogFormatterFactory',
],
],
'search' => [
@ -474,7 +476,8 @@ class ApiQuery extends ApiBase {
'NamespaceInfo',
'GenderCache',
'CommentFormatter',
'TempUserConfig'
'TempUserConfig',
'LogFormatterFactory',
],
],
'watchlistraw' => [

View file

@ -46,6 +46,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
private CommentFormatter $commentFormatter;
private NameTableStore $changeTagDefStore;
private UserNameUtils $userNameUtils;
private LogFormatterFactory $logFormatterFactory;
/** @var string[]|null */
private $formattedComments;
@ -57,6 +58,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
* @param RowCommentFormatter $commentFormatter
* @param NameTableStore $changeTagDefStore
* @param UserNameUtils $userNameUtils
* @param LogFormatterFactory $logFormatterFactory
*/
public function __construct(
ApiQuery $query,
@ -64,13 +66,15 @@ class ApiQueryLogEvents extends ApiQueryBase {
CommentStore $commentStore,
RowCommentFormatter $commentFormatter,
NameTableStore $changeTagDefStore,
UserNameUtils $userNameUtils
UserNameUtils $userNameUtils,
LogFormatterFactory $logFormatterFactory
) {
parent::__construct( $query, $moduleName, 'le' );
$this->commentStore = $commentStore;
$this->commentFormatter = $commentFormatter;
$this->changeTagDefStore = $changeTagDefStore;
$this->userNameUtils = $userNameUtils;
$this->logFormatterFactory = $logFormatterFactory;
}
private bool $fld_ids = false;
@ -357,7 +361,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
}
}
if ( $this->fld_details ) {
$vals['params'] = LogFormatter::newFromEntry( $logEntry )->formatParametersForApi();
$vals['params'] = $this->logFormatterFactory->newFromEntry( $logEntry )->formatParametersForApi();
}
}
}

View file

@ -52,6 +52,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
private SlotRoleRegistry $slotRoleRegistry;
private UserNameUtils $userNameUtils;
private TempUserConfig $tempUserConfig;
private LogFormatterFactory $logFormatterFactory;
private $formattedComments = [];
@ -65,6 +66,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
* @param SlotRoleRegistry $slotRoleRegistry
* @param UserNameUtils $userNameUtils
* @param TempUserConfig $tempUserConfig
* @param LogFormatterFactory $logFormatterFactory
*/
public function __construct(
ApiQuery $query,
@ -75,7 +77,8 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
NameTableStore $slotRoleStore,
SlotRoleRegistry $slotRoleRegistry,
UserNameUtils $userNameUtils,
TempUserConfig $tempUserConfig
TempUserConfig $tempUserConfig,
LogFormatterFactory $logFormatterFactory
) {
parent::__construct( $query, $moduleName, 'rc' );
$this->commentStore = $commentStore;
@ -85,6 +88,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
$this->slotRoleRegistry = $slotRoleRegistry;
$this->userNameUtils = $userNameUtils;
$this->tempUserConfig = $tempUserConfig;
$this->logFormatterFactory = $logFormatterFactory;
}
private bool $fld_comment = false;
@ -647,7 +651,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
$vals['logid'] = (int)$row->rc_logid;
$vals['logtype'] = $row->rc_log_type;
$vals['logaction'] = $row->rc_log_action;
$vals['logparams'] = LogFormatter::newFromRow( $row )->formatParametersForApi();
$vals['logparams'] = $this->logFormatterFactory->newFromRow( $row )->formatParametersForApi();
}
}

View file

@ -49,6 +49,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
private GenderCache $genderCache;
private CommentFormatter $commentFormatter;
private TempUserConfig $tempUserConfig;
private LogFormatterFactory $logFormatterFactory;
/**
* @param ApiQuery $query
@ -60,6 +61,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
* @param GenderCache $genderCache
* @param CommentFormatter $commentFormatter
* @param TempUserConfig $tempUserConfig
* @param LogFormatterFactory $logFormatterFactory
*/
public function __construct(
ApiQuery $query,
@ -70,7 +72,8 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
NamespaceInfo $namespaceInfo,
GenderCache $genderCache,
CommentFormatter $commentFormatter,
TempUserConfig $tempUserConfig
TempUserConfig $tempUserConfig,
LogFormatterFactory $logFormatterFactory
) {
parent::__construct( $query, $moduleName, 'wl' );
$this->commentStore = $commentStore;
@ -80,6 +83,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
$this->genderCache = $genderCache;
$this->commentFormatter = $commentFormatter;
$this->tempUserConfig = $tempUserConfig;
$this->logFormatterFactory = $logFormatterFactory;
}
public function execute() {
@ -455,7 +459,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
$vals['logtype'] = $recentChangeInfo['rc_log_type'];
$vals['logaction'] = $recentChangeInfo['rc_log_action'];
$logFormatter = LogFormatter::newFromRow( $recentChangeInfo );
$logFormatter = $this->logFormatterFactory->newFromRow( $recentChangeInfo );
$vals['logparams'] = $logFormatter->formatParametersForApi();
$vals['logdisplay'] = $logFormatter->getActionText();
}

View file

@ -94,6 +94,8 @@ class ChangesList extends ContextSource {
*/
protected $userLinkCache;
private LogFormatterFactory $logFormatterFactory;
/**
* @param IContextSource $context
* @param ChangesListFilterGroup[] $filterGroups Array of ChangesListFilterGroup objects (currently optional)
@ -107,6 +109,7 @@ class ChangesList extends ContextSource {
$services = MediaWikiServices::getInstance();
$this->linkRenderer = $services->getLinkRenderer();
$this->commentFormatter = $services->getRowCommentFormatter();
$this->logFormatterFactory = $services->getLogFormatterFactory();
$this->tagsCache = new MapCacheLRU( 50 );
$this->userLinkCache = new MapCacheLRU( 50 );
}
@ -751,7 +754,7 @@ class ChangesList extends ContextSource {
* @return string
*/
public function insertLogEntry( $rc ) {
$formatter = LogFormatter::newFromRow( $rc->mAttribs );
$formatter = $this->logFormatterFactory->newFromRow( $rc->mAttribs );
$formatter->setContext( $this->getContext() );
$formatter->setShowUserToolLinks( true );
$mark = $this->getLanguage()->getDirMark();

View file

@ -77,12 +77,13 @@ class ChangeTagsLogItem extends RevisionItemBase {
$date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
$this->row->log_timestamp, $this->list->getUser() ) );
$title = Title::makeTitle( $this->row->log_namespace, $this->row->log_title );
$formatter = LogFormatter::newFromRow( $this->row );
$services = MediaWikiServices::getInstance();
$formatter = $services->getLogFormatterFactory()->newFromRow( $this->row );
$formatter->setContext( $this->list->getContext() );
$formatter->setAudience( LogFormatter::FOR_THIS_USER );
// Log link for this page
$loglink = MediaWikiServices::getInstance()->getLinkRenderer()->makeLink(
$loglink = $services->getLinkRenderer()->makeLink(
SpecialPage::getTitleFor( 'Log' ),
$this->list->msg( 'log' )->text(),
[],

View file

@ -34,6 +34,7 @@ class ContentModelChange {
private $revLookup;
/** @var UserFactory */
private $userFactory;
private LogFormatterFactory $logFormatterFactory;
/** @var Authority making the change */
private $performer;
/** @var WikiPage */
@ -60,6 +61,7 @@ class ContentModelChange {
* @param RevisionLookup $revLookup
* @param UserFactory $userFactory
* @param WikiPageFactory $wikiPageFactory
* @param LogFormatterFactory $logFormatterFactory
* @param Authority $performer
* @param PageIdentity $page
* @param string $newModel
@ -70,6 +72,7 @@ class ContentModelChange {
RevisionLookup $revLookup,
UserFactory $userFactory,
WikiPageFactory $wikiPageFactory,
LogFormatterFactory $logFormatterFactory,
Authority $performer,
PageIdentity $page,
string $newModel
@ -78,6 +81,7 @@ class ContentModelChange {
$this->hookRunner = new HookRunner( $hookContainer );
$this->revLookup = $revLookup;
$this->userFactory = $userFactory;
$this->logFormatterFactory = $logFormatterFactory;
$this->performer = $performer;
$this->page = $wikiPageFactory->newFromTitle( $page );
@ -283,7 +287,7 @@ class ContentModelChange {
] );
$log->addTags( $this->tags );
$formatter = LogFormatter::newFromEntry( $log );
$formatter = $this->logFormatterFactory->newFromEntry( $log );
$formatter->setContext( RequestContext::newExtraneousContext( $title ) );
$reason = $formatter->getPlainActionText();

View file

@ -1896,9 +1896,10 @@ class LocalFile extends File {
if ( $descTitle->exists() ) {
if ( $createNullRevision ) {
$revStore = MediaWikiServices::getInstance()->getRevisionStore();
$services = MediaWikiServices::getInstance();
$revStore = $services->getRevisionStore();
// Use own context to get the action text in content language
$formatter = LogFormatter::newFromEntry( $logEntry );
$formatter = $services->getLogFormatterFactory()->newFromEntry( $logEntry );
$formatter->setContext( RequestContext::newExtraneousContext( $descTitle ) );
$editSummary = $formatter->getPlainActionText();
$summary = CommentStoreComment::newUnsavedComment( $editSummary );

View file

@ -67,6 +67,8 @@ class LogEventsList extends ContextSource {
/** @var HookRunner */
private $hookRunner;
private LogFormatterFactory $logFormatterFactory;
/** @var MapCacheLRU */
private $tagsCache;
@ -83,7 +85,9 @@ class LogEventsList extends ContextSource {
if ( $linkRenderer instanceof LinkRenderer ) {
$this->linkRenderer = $linkRenderer;
}
$this->hookRunner = new HookRunner( MediaWikiServices::getInstance()->getHookContainer() );
$services = MediaWikiServices::getInstance();
$this->hookRunner = new HookRunner( $services->getHookContainer() );
$this->logFormatterFactory = $services->getLogFormatterFactory();
$this->tagsCache = new MapCacheLRU( 50 );
}
@ -318,9 +322,8 @@ class LogEventsList extends ContextSource {
*/
public function logLine( $row ) {
$entry = DatabaseLogEntry::newFromRow( $row );
$formatter = LogFormatter::newFromEntry( $entry );
$formatter = $this->logFormatterFactory->newFromEntry( $entry );
$formatter->setContext( $this->getContext() );
$formatter->setLinkRenderer( $this->getLinkRenderer() );
$formatter->setShowUserToolLinks( !( $this->flags & self::NO_EXTRA_USER_LINKS ) );
$time = $this->getLanguage()->userTimeAndDate(
@ -615,7 +618,8 @@ class LogEventsList extends ContextSource {
'',
0,
$services->getLinkBatchFactory(),
$services->getActorNormalization()
$services->getActorNormalization(),
$services->getLogFormatterFactory()
);
// @phan-suppress-next-line PhanImpossibleCondition
if ( !$useRequestParams ) {

View file

@ -372,7 +372,7 @@ class LogPage {
// needed to say the LogFormatter the parameters have numeric keys
$logEntry->setLegacy( true );
$formatter = LogFormatter::newFromEntry( $logEntry );
$formatter = MediaWikiServices::getInstance()->getLogFormatterFactory()->newFromEntry( $logEntry );
$context = RequestContext::newExtraneousContext( $target );
$formatter->setContext( $context );

View file

@ -27,7 +27,7 @@ namespace MediaWiki\Pager;
use DatabaseLogEntry;
use LogEventsList;
use LogFormatter;
use LogFormatterFactory;
use LogPage;
use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\MainConfigNames;
@ -83,6 +83,7 @@ class LogPager extends ReverseChronologicalPager {
/** @var ActorNormalization */
private $actorNormalization;
private LogFormatterFactory $logFormatterFactory;
/**
* @param LogEventsList $list
@ -99,6 +100,7 @@ class LogPager extends ReverseChronologicalPager {
* @param int $logId Log entry ID, to limit to a single log entry.
* @param LinkBatchFactory|null $linkBatchFactory
* @param ActorNormalization|null $actorNormalization
* @param LogFormatterFactory|null $logFormatterFactory
* @param bool $tagInvert whether tags are filtered for (false) or out (true)
*/
public function __construct( $list, $types = [], $performer = '', $page = '',
@ -106,6 +108,7 @@ class LogPager extends ReverseChronologicalPager {
$tagFilter = '', $action = '', $logId = 0,
LinkBatchFactory $linkBatchFactory = null,
ActorNormalization $actorNormalization = null,
LogFormatterFactory $logFormatterFactory = null,
$tagInvert = false
) {
parent::__construct( $list->getContext() );
@ -117,6 +120,7 @@ class LogPager extends ReverseChronologicalPager {
// Class is used directly in extensions - T266480
$this->linkBatchFactory = $linkBatchFactory ?? $services->getLinkBatchFactory();
$this->actorNormalization = $actorNormalization ?? $services->getActorNormalization();
$this->logFormatterFactory = $logFormatterFactory ?? $services->getLogFormatterFactory();
$this->limitLogId( $logId ); // set before types per T269761
$this->limitType( $types ); // also excludes hidden types
@ -444,7 +448,7 @@ class LogPager extends ReverseChronologicalPager {
$lb->add( $row->log_namespace, $row->log_title );
$lb->add( NS_USER, $row->log_user_text );
$lb->add( NS_USER_TALK, $row->log_user_text );
$formatter = LogFormatter::newFromRow( $row );
$formatter = $this->logFormatterFactory->newFromRow( $row );
foreach ( $formatter->getPreloadTitles() as $title ) {
$lb->addObj( $title );
}

View file

@ -371,7 +371,7 @@ class ManualLogEntry extends LogEntryBase implements Taggable {
* @since 1.23
*/
public function getRecentChange( $newId = 0 ) {
$formatter = LogFormatter::newFromEntry( $this );
$formatter = MediaWikiServices::getInstance()->getLogFormatterFactory()->newFromEntry( $this );
$context = RequestContext::newExtraneousContext( $this->getTarget() );
$formatter->setContext( $context );

View file

@ -24,7 +24,7 @@ use ChangeTags;
use ContentHandler;
use File;
use IDBAccessObject;
use LogFormatter;
use LogFormatterFactory;
use ManualLogEntry;
use MediaWiki\Collation\CollationFactory;
use MediaWiki\CommentStore\CommentStoreComment;
@ -85,6 +85,7 @@ class MovePage {
private PageUpdaterFactory $pageUpdaterFactory;
private RestrictionStore $restrictionStore;
private DeletePageFactory $deletePageFactory;
private LogFormatterFactory $logFormatterFactory;
/** @var int */
private $maximumMovedPages;
@ -119,7 +120,8 @@ class MovePage {
CollationFactory $collationFactory,
PageUpdaterFactory $pageUpdaterFactory,
RestrictionStore $restrictionStore,
DeletePageFactory $deletePageFactory
DeletePageFactory $deletePageFactory,
LogFormatterFactory $logFormatterFactory
) {
$this->oldTitle = $oldTitle;
$this->newTitle = $newTitle;
@ -141,6 +143,7 @@ class MovePage {
$this->pageUpdaterFactory = $pageUpdaterFactory;
$this->restrictionStore = $restrictionStore;
$this->deletePageFactory = $deletePageFactory;
$this->logFormatterFactory = $logFormatterFactory;
$this->maximumMovedPages = $this->options->get( MainConfigNames::MaximumMovedPages );
}
@ -873,7 +876,7 @@ class MovePage {
'5::noredir' => $redirectContent ? '0' : '1',
] );
$formatter = LogFormatter::newFromEntry( $logEntry );
$formatter = $this->logFormatterFactory->newFromEntry( $logEntry );
$formatter->setContext( RequestContext::newExtraneousContext( $this->oldTitle ) );
$comment = $formatter->getPlainActionText();
if ( $reason ) {

View file

@ -23,6 +23,7 @@ namespace MediaWiki\Page;
use ContentModelChange;
use JobQueueGroup;
use LogFormatterFactory;
use MediaWiki\Cache\BacklinkCacheFactory;
use MediaWiki\Collation\CollationFactory;
use MediaWiki\CommentStore\CommentStore;
@ -99,6 +100,7 @@ class PageCommandFactory implements
private RestrictionStore $restrictionStore;
private LinkTargetLookup $linkTargetLookup;
private RedirectStore $redirectStore;
private LogFormatterFactory $logFormatterFactory;
public function __construct(
Config $config,
@ -131,7 +133,8 @@ class PageCommandFactory implements
ArchivedRevisionLookup $archivedRevisionLookup,
RestrictionStore $restrictionStore,
LinkTargetLookup $linkTargetLookup,
RedirectStore $redirectStore
RedirectStore $redirectStore,
LogFormatterFactory $logFormatterFactory
) {
$this->config = $config;
$this->lbFactory = $lbFactory;
@ -164,6 +167,7 @@ class PageCommandFactory implements
$this->restrictionStore = $restrictionStore;
$this->linkTargetLookup = $linkTargetLookup;
$this->redirectStore = $redirectStore;
$this->logFormatterFactory = $logFormatterFactory;
}
/**
@ -183,6 +187,7 @@ class PageCommandFactory implements
$this->revisionStoreFactory->getRevisionStore(),
$this->userFactory,
$this->wikiPageFactory,
$this->logFormatterFactory,
$performer,
$page,
$newContentModel
@ -268,7 +273,8 @@ class PageCommandFactory implements
$this->collationFactory,
$this->pageUpdaterFactory,
$this->restrictionStore,
$this
$this,
$this->logFormatterFactory
);
}

View file

@ -34,22 +34,26 @@ class RevDelLogItem extends RevDelItem {
/** @var CommentStore */
private $commentStore;
private IConnectionProvider $dbProvider;
private LogFormatterFactory $logFormatterFactory;
/**
* @param RevisionListBase $list
* @param stdClass $row DB result row
* @param CommentStore $commentStore
* @param IConnectionProvider $dbProvider
* @param LogFormatterFactory $logFormatterFactory
*/
public function __construct(
RevisionListBase $list,
$row,
CommentStore $commentStore,
IConnectionProvider $dbProvider
IConnectionProvider $dbProvider,
LogFormatterFactory $logFormatterFactory
) {
parent::__construct( $list, $row );
$this->commentStore = $commentStore;
$this->dbProvider = $dbProvider;
$this->logFormatterFactory = $logFormatterFactory;
}
public function getIdField() {
@ -122,7 +126,7 @@ class RevDelLogItem extends RevDelItem {
$date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
$this->row->log_timestamp, $this->list->getUser() ) );
$title = Title::makeTitle( $this->row->log_namespace, $this->row->log_title );
$formatter = LogFormatter::newFromRow( $this->row );
$formatter = $this->logFormatterFactory->newFromRow( $this->row );
$formatter->setContext( $this->list->getContext() );
$formatter->setAudience( LogFormatter::FOR_THIS_USER );
@ -167,7 +171,7 @@ class RevDelLogItem extends RevDelItem {
];
if ( LogEventsList::userCan( $this->row, LogPage::DELETED_ACTION, $user ) ) {
$ret['params'] = LogFormatter::newFromEntry( $logEntry )->formatParametersForApi();
$ret['params'] = $this->logFormatterFactory->newFromEntry( $logEntry )->formatParametersForApi();
}
if ( LogEventsList::userCan( $this->row, LogPage::DELETED_USER, $user ) ) {
$ret += [

View file

@ -37,6 +37,7 @@ class RevDelLogList extends RevDelList {
/** @var CommentStore */
private $commentStore;
private LogFormatterFactory $logFormatterFactory;
/**
* @internal Use RevisionDeleter
@ -45,16 +46,19 @@ class RevDelLogList extends RevDelList {
* @param array $ids
* @param LBFactory $lbFactory
* @param CommentStore $commentStore
* @param LogFormatterFactory $logFormatterFactory
*/
public function __construct(
IContextSource $context,
PageIdentity $page,
array $ids,
LBFactory $lbFactory,
CommentStore $commentStore
CommentStore $commentStore,
LogFormatterFactory $logFormatterFactory
) {
parent::__construct( $context, $page, $ids, $lbFactory );
$this->commentStore = $commentStore;
$this->logFormatterFactory = $logFormatterFactory;
}
public function getType() {
@ -129,7 +133,8 @@ class RevDelLogList extends RevDelList {
$this,
$row,
$this->commentStore,
MediaWikiServices::getInstance()->getConnectionProvider()
MediaWikiServices::getInstance()->getConnectionProvider(),
$this->logFormatterFactory
);
}

View file

@ -78,6 +78,7 @@ class RevisionDeleter {
'services' => [
'DBLoadBalancerFactory',
'CommentStore',
'LogFormatterFactory',
],
],
];

View file

@ -25,7 +25,6 @@ use ChangesListBooleanFilterGroup;
use ChangesListFilterGroup;
use ChangesListStringOptionsFilterGroup;
use ChangeTags;
use LogFormatter;
use MediaWiki\Context\IContextSource;
use MediaWiki\Html\FormOptions;
use MediaWiki\Html\Html;
@ -682,7 +681,9 @@ abstract class ChangesListSpecialPage extends SpecialPage {
return;
}
$linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
$services = MediaWikiServices::getInstance();
$logFormatterFactory = $services->getLogFormatterFactory();
$linkBatchFactory = $services->getLinkBatchFactory();
$batch = $linkBatchFactory->newLinkBatch();
$userNames = [];
foreach ( $rows as $row ) {
@ -691,7 +692,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
$userNames[] = $row->rc_user_text;
$batch->add( $row->rc_namespace, $row->rc_title );
if ( $row->rc_source === RecentChange::SRC_LOG ) {
$formatter = LogFormatter::newFromRow( $row );
$formatter = $logFormatterFactory->newFromRow( $row );
foreach ( $formatter->getPreloadTitles() as $title ) {
$batch->addObj( $title );
if ( $title->inNamespace( NS_USER ) || $title->inNamespace( NS_USER_TALK ) ) {

View file

@ -700,6 +700,7 @@ class SpecialPageFactory {
'ActorNormalization',
'UserIdentityLookup',
'UserNameUtils',
'LogFormatterFactory',
]
],
'Watchlist' => [

View file

@ -22,6 +22,7 @@ namespace MediaWiki\Specials;
use ChangeTags;
use LogEventsList;
use LogFormatterFactory;
use LogPage;
use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\HookContainer\HookRunner;
@ -59,19 +60,23 @@ class SpecialLog extends SpecialPage {
private UserNameUtils $userNameUtils;
private LogFormatterFactory $logFormatterFactory;
/**
* @param LinkBatchFactory $linkBatchFactory
* @param IConnectionProvider $dbProvider
* @param ActorNormalization $actorNormalization
* @param UserIdentityLookup $userIdentityLookup
* @param UserNameUtils $userNameUtils
* @param LogFormatterFactory $logFormatterFactory
*/
public function __construct(
LinkBatchFactory $linkBatchFactory,
IConnectionProvider $dbProvider,
ActorNormalization $actorNormalization,
UserIdentityLookup $userIdentityLookup,
UserNameUtils $userNameUtils
UserNameUtils $userNameUtils,
LogFormatterFactory $logFormatterFactory
) {
parent::__construct( 'Log' );
$this->linkBatchFactory = $linkBatchFactory;
@ -79,6 +84,7 @@ class SpecialLog extends SpecialPage {
$this->actorNormalization = $actorNormalization;
$this->userIdentityLookup = $userIdentityLookup;
$this->userNameUtils = $userNameUtils;
$this->logFormatterFactory = $logFormatterFactory;
}
public function execute( $par ) {
@ -275,6 +281,7 @@ class SpecialLog extends SpecialPage {
$opts->getValue( 'logid' ),
$this->linkBatchFactory,
$this->actorNormalization,
$this->logFormatterFactory,
$opts->getValue( 'tagInvert' )
);

View file

@ -6,7 +6,6 @@ use MediaWiki\Config\ServiceOptions;
use MediaWiki\Context\RequestContext;
use MediaWiki\Linker\LinkRenderer;
use MediaWiki\Linker\LinkTarget;
use MediaWiki\MediaWikiServices;
use MediaWiki\Page\ExistingPageRecord;
use MediaWiki\Page\PageStore;
use MediaWiki\Tests\Unit\Permissions\MockAuthorityTrait;
@ -26,18 +25,18 @@ abstract class LogFormatterTestCase extends MediaWikiLangTestCase {
RequestContext::resetMain();
$row = $this->expandDatabaseRow( $row, $this->isLegacy( $extra ) );
$services = $this->getServiceContainer();
$userGroups = (array)$userGroups;
$userRights = MediaWikiServices::getInstance()->getGroupPermissionsLookup()->getGroupPermissions( $userGroups );
$userRights = $services->getGroupPermissionsLookup()->getGroupPermissions( $userGroups );
$context = new RequestContext();
$authority = $this->mockRegisteredAuthorityWithPermissions( $userRights );
$context->setAuthority( $authority );
$context->setLanguage( 'en' );
$formatter = LogFormatter::newFromRow( $row );
$formatter = $services->getLogFormatterFactory()->newFromRow( $row );
$formatter->setContext( $context );
// Create a LinkRenderer without LinkCache to avoid DB access
$services = $this->getServiceContainer();
$realLinkRenderer = new LinkRenderer(
$services->getTitleFormatter(),
$this->createMock( LinkCache::class ),

View file

@ -482,7 +482,7 @@ class ProtectLogFormatterTest extends LogFormatterTestCase {
$context = new RequestContext();
$context->setAuthority( $user );
$context->setLanguage( 'en' );
$formatter = LogFormatter::newFromRow( $row );
$formatter = $this->getServiceContainer()->getLogFormatterFactory()->newFromRow( $row );
$formatter->setContext( $context );
$titleFactory = $this->createMock( TitleFactory::class );
$titleFactory->method( 'makeTitle' )->willReturnCallback( static function () {

View file

@ -64,7 +64,8 @@ class MovePageTest extends MediaWikiIntegrationTestCase {
$this->getServiceContainer()->getCollationFactory(),
$this->getServiceContainer()->getPageUpdaterFactory(),
$this->getServiceContainer()->getRestrictionStore(),
$this->getServiceContainer()->getDeletePageFactory()
$this->getServiceContainer()->getDeletePageFactory(),
$this->getServiceContainer()->getLogFormatterFactory()
);
}

View file

@ -29,7 +29,8 @@ class SpecialLogTest extends SpecialPageTestBase {
$services->getConnectionProvider(),
$services->getActorNormalization(),
$services->getUserIdentityLookup(),
$services->getUserNameUtils()
$services->getUserNameUtils(),
$services->getLogFormatterFactory()
);
}