From 497e8df608cca6ca01c3ba277207415b54f17c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Mon, 4 Sep 2023 19:15:25 +0200 Subject: [PATCH] Remove 'VisualEditorTransitionDefault' and AutodisableVisualEditorPref.php Bug: T344759 Change-Id: Ib268fd493070a646a49799dc5fb8a4774e25ec3e --- extension.json | 3 - includes/Hooks.php | 10 +-- maintenance/AutodisableVisualEditorPref.php | 76 --------------------- 3 files changed, 2 insertions(+), 87 deletions(-) delete mode 100644 maintenance/AutodisableVisualEditorPref.php diff --git a/extension.json b/extension.json index e20552e1b3..bb962836d7 100644 --- a/extension.json +++ b/extension.json @@ -143,9 +143,6 @@ "VisualEditorTabPosition": { "value": "before" }, - "VisualEditorTransitionDefault": { - "value": false - }, "VisualEditorUseChangeTagging": { "value": true, "description": "Tag edits as having used visualeditor, or VE's wikitext mode." diff --git a/includes/Hooks.php b/includes/Hooks.php index f1cc9445d4..0962907ec7 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -960,6 +960,8 @@ class Hooks implements // This is saved even when VE is off by default, which allows changing it to be on by default // without affecting the users who opted out. There's also a maintenance script to silently // opt-out existing users en masse before changing the default, thus only affecting new users. + // (This option is no longer set to 'true' anywhere, but we can still encounter old true + // values until they are migrated: T344760.) $preferences['visualeditor-autodisable'] = $api; // The diff mode is persisted for each editor mode separately, // e.g. use visual diffs for visual mode only. @@ -1007,14 +1009,6 @@ class Hooks implements !$userOptionsManager->getOption( $user, 'visualeditor-betatempdisable' ) ) ) { $userOptionsManager->setOption( $user, 'visualeditor-autodisable', false ); - } elseif ( - // When the user disables VE (and we're in beta, but about to go opt-out), set the preference. - $veConfig->get( 'VisualEditorTransitionDefault' ) && - $isBeta && - !$userOptionsManager->getOption( $user, 'visualeditor-enable' ) && - !$userOptionsManager->getOption( $user, 'visualeditor-autodisable' ) - ) { - $userOptionsManager->setOption( $user, 'visualeditor-autodisable', true ); } } diff --git a/maintenance/AutodisableVisualEditorPref.php b/maintenance/AutodisableVisualEditorPref.php deleted file mode 100644 index b47c70bc03..0000000000 --- a/maintenance/AutodisableVisualEditorPref.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @file - * @ingroup Extensions - * @ingroup Maintenance - */ - -use MediaWiki\MediaWikiServices; - -$maintenancePath = getenv( 'MW_INSTALL_PATH' ) !== false - ? getenv( 'MW_INSTALL_PATH' ) . '/maintenance/Maintenance.php' - : __DIR__ . '/../../../../maintenance/Maintenance.php'; - -require_once $maintenancePath; - -class AutodisableVisualEditorPref extends Maintenance { - - /** - * @inheritDoc - */ - public function __construct() { - parent::__construct(); - $this->requireExtension( 'VisualEditor' ); - $this->addDescription( "Sets the VisualEditor autodisable preference on appropriate users." ); - $this->setBatchSize( 500 ); - } - - /** - * @inheritDoc - */ - public function execute() { - $dbr = wfGetDB( DB_REPLICA ); - $services = MediaWikiServices::getInstance(); - $lbFactory = $services->getDBLoadBalancerFactory(); - $userOptionsManager = $services->getUserOptionsManager(); - - $lastUserId = -1; - do { - $results = $dbr->newSelectQueryBuilder() - ->from( 'user' ) - ->leftJoin( 'user_properties', null, [ - 'user_id = up_user', - 'up_property' => "visualeditor-enable" - ] ) - ->field( 'user_id' ) - ->where( [ - 'user_id > ' . $dbr->addQuotes( $lastUserId ), - // only select users with no entry in user_properties - 'up_value IS NULL', - 'user_editcount > 0' - ] ) - ->limit( $this->mBatchSize ) - ->orderBy( 'user_id' ) - ->caller( __METHOD__ ) - ->fetchResultSet(); - foreach ( $results as $userRow ) { - $user = User::newFromId( $userRow->user_id ); - $user->load( User::READ_LATEST ); - $userOptionsManager->setOption( $user, 'visualeditor-autodisable', true ); - $user->saveSettings(); - $lastUserId = $userRow->user_id; - } - $this->output( "Added preference for " . $results->numRows() . " users.\n" ); - $lbFactory->waitForReplication(); - } while ( $results->numRows() == $this->mBatchSize ); - $this->output( "done.\n" ); - } -} - -$maintClass = AutodisableVisualEditorPref::class; -require_once RUN_MAINTENANCE_IF_MAIN;