mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-23 16:06:53 +00:00
NewTopicOptOutActiveUsers: Skip bot users etc.
Bug: T317375
Change-Id: I7b83d1b0a9c450ae5eefa5b6f7ebd9ef4c1f22a1
(cherry picked from commit eede5f73de
)
This commit is contained in:
parent
3a13c4eb03
commit
9a97e7f99b
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue