From 35637c029a557326b2dce5f435334a36f6deed3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Laxstr=C3=B6m?= Date: Mon, 2 Oct 2023 13:35:46 +0300 Subject: [PATCH] Remove unused ULSCompactLinksDisablePref script Only used 6 years ago, contains deprecated code Change-Id: Ib4ba28a60aca9e9eba40a5f1cb59489b729a0fcb --- maintenance/ULSCompactLinksDisablePref.php | 126 --------------------- 1 file changed, 126 deletions(-) delete mode 100644 maintenance/ULSCompactLinksDisablePref.php diff --git a/maintenance/ULSCompactLinksDisablePref.php b/maintenance/ULSCompactLinksDisablePref.php deleted file mode 100644 index f31733b4..00000000 --- a/maintenance/ULSCompactLinksDisablePref.php +++ /dev/null @@ -1,126 +0,0 @@ -requireExtension( 'UniversalLanguageSelector' ); - $this->addDescription( 'Disables the UniversalLanguageSelector compact-language-links ' . - 'preference for appropriate users.' ); - $this->setBatchSize( 100 ); - - $this->addOption( 'really', 'Really change the preferences' ); - - $this->addOption( 'continue', 'Continue running from this user ID', false, true ); - } - - public function execute() { - $dbr = wfGetDB( DB_REPLICA, 'vslow' ); - $services = MediaWikiServices::getInstance(); - $lbFactory = $services->getDBLoadBalancerFactory(); - $userOptionsManager = $services->getUserOptionsManager(); - - $really = $this->hasOption( 'really' ); - - $lastUserId = $this->getOption( 'continue', 0 ); - - if ( class_exists( ActorMigration::class ) ) { - $actorQuery = ActorMigration::newMigration()->getJoin( 'rev_user' ); - $revUser = $actorQuery['fields']['rev_user']; - } else { - $actorQuery = [ - 'tables' => [], - 'joins' => [], - ]; - $revUser = 'rev_user'; - } - - do { - $tables = array_merge( - [ 'revision' ], - $actorQuery['tables'], - [ 'user_properties', 'user_groups' ] - ); - $fields = [ - 'user' => $revUser, - 'isbot' => 'ug_group', - 'hasbeta' => 'up_value' - ]; - $conds = [ - 'rev_timestamp > ' . $dbr->timestamp( 20170101000000 ), - "$revUser > $lastUserId" - ]; - $options = [ - 'GROUP BY' => $revUser, - 'ORDER BY' => 'user', - 'LIMIT' => $this->mBatchSize, - ]; - $joins = [ - 'user_properties' => [ - 'LEFT OUTER JOIN', - "$revUser = up_user AND up_property = 'uls-compact-links' AND up_value = 1" - ], - 'user_groups' => [ - 'LEFT OUTER JOIN', - "$revUser = ug_user AND ug_group = 'bot'" - ] - ] + $actorQuery['joins']; - - if ( !$really ) { - echo "\n\n" . - $dbr->selectSqlText( $tables, $fields, $conds, __METHOD__, $options, $joins ) . - "\n"; - } - - $results = $dbr->select( $tables, $fields, $conds, __METHOD__, $options, $joins ); - - $disabled = 0; - - foreach ( $results as $row ) { - $lastUserId = $row->user; - if ( $row->isbot === 'bot' || $row->hasbeta !== null ) { - continue; - } - - $user = User::newFromId( $lastUserId ); - $user->load( User::READ_LATEST ); - - if ( $really ) { - $userOptionsManager->setOption( $user, 'compact-language-links', 0 ); - - $user->saveSettings(); - } - - $disabled++; - // If we ever need to revert, print the affected user ids - $this->output( $row->user . " ", 'userids' ); - } - - $this->output( "Disabled compact-language-links for $disabled users.\n" ); - $lbFactory->waitForReplication(); - } while ( $results->numRows() === $this->mBatchSize ); - - $this->output( "done.\n" ); - } -} - -$maintClass = ULSCompactLinksDisablePref::class; -require_once RUN_MAINTENANCE_IF_MAIN;