Remove 'VisualEditorTransitionDefault' and AutodisableVisualEditorPref.php

Bug: T344759
Change-Id: Ib268fd493070a646a49799dc5fb8a4774e25ec3e
This commit is contained in:
Bartosz Dziewoński 2023-09-04 19:15:25 +02:00
parent c180c2f58e
commit 497e8df608
3 changed files with 2 additions and 87 deletions

View file

@ -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."

View file

@ -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 );
}
}

View file

@ -1,76 +0,0 @@
<?php
/**
* Sets the VisualEditor autodisable preference on appropriate users.
*
* @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt
* @license MIT
* @author Alex Monk <amonk@wikimedia.org>
* @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;