From eede5f73dec1ab926604b3b40dc3bd2860551dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Wed, 17 May 2023 17:31:44 +0200 Subject: [PATCH] NewTopicOptOutActiveUsers: Skip bot users etc. Bug: T317375 Change-Id: I7b83d1b0a9c450ae5eefa5b6f7ebd9ef4c1f22a1 --- maintenance/NewTopicOptOutActiveUsers.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/maintenance/NewTopicOptOutActiveUsers.php b/maintenance/NewTopicOptOutActiveUsers.php index 3931c37f6..03c26078d 100644 --- a/maintenance/NewTopicOptOutActiveUsers.php +++ b/maintenance/NewTopicOptOutActiveUsers.php @@ -5,10 +5,13 @@ namespace MediaWiki\Extension\DiscussionTools\Maintenance; use IDatabase; use Maintenance; use MediaWiki\Extension\DiscussionTools\Hooks\HookUtils; +use MediaWiki\MediaWikiServices; +use MediaWiki\User\UserFactory; class NewTopicOptOutActiveUsers extends Maintenance { private IDatabase $dbw; + private UserFactory $userFactory; public function __construct() { parent::__construct(); @@ -33,6 +36,7 @@ class NewTopicOptOutActiveUsers extends Maintenance { } $this->dbw = $this->getDB( DB_PRIMARY ); + $this->userFactory = MediaWikiServices::getInstance()->getUserFactory(); $userRows = $this->dbw->newSelectQueryBuilder() ->caller( __METHOD__ ) @@ -102,6 +106,18 @@ class NewTopicOptOutActiveUsers extends Maintenance { return 'betaenable'; } + // Skip accounts that shouldn't have non-default preferences + $user = $this->userFactory->newFromId( $userId ); + if ( $user->isSystemUser() ) { + return 'system'; + } + if ( $user->isBot() ) { + return 'bot'; + } + if ( $user->isTemp() ) { + return 'temp'; + } + return null; }