addDescription( 'Update activated-editor users by editor history.' ); $this->setBatchSize( 300 ); $this->requireExtension( 'IsekaiMisc' ); } /** * Return all users * @return IResultWrapper */ private function getUserRes() { return $this->dbr->select( [ 'user' ], [ 'user_id', 'user_name', ], [ 'user_editcount > 0' ], __METHOD__ ); } public function execute() { $this->services = MediaWikiServices::getInstance(); $this->dbr = $this->services->getDBLoadBalancer()->getConnection(DB_REPLICA); $this->config = $this->services->getMainConfig(); $userFactory = $this->services->getUserFactory(); $userGroupManager = $this->services->getUserGroupManager(); $requiredWords = $this->config->get('IsekaiActivateEditorRequiredWords'); $groupedUserIds = []; $res = $this->getUserRes(NS_MAIN); foreach ($res as $row) { $continueKey = null; $userCreditSize = 0; $user = $userFactory->newFromId($row->user_id); $this->output('Checking user "' . $user->getName() . '"...' . PHP_EOL); if (MiscUtils::checkUserIsActivatedEditor($user)) { $this->output(' Adding user "' . $user->getName() . '" to activated-editor group' . PHP_EOL); $userGroupManager->addUserToGroup($user, 'activated-editor'); } } } } $maintClass = UpdateActivatedEditor::class; require_once RUN_MAINTENANCE_IF_MAIN;