mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
4a7bf9d894
* Load users from master, probably not useful until I4ffc8325 goes in * Don't bother with extra query for 0 users at the end, stop when we get less users than our batch size limit. Bug: T112352 Change-Id: Ie800a5aa3b134301ead75cc5b3ae112f29589e3c
65 lines
1.8 KiB
PHP
65 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* Sets the VisualEditor autodisable preference on appropriate users.
|
|
*
|
|
* @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
* @author Alex Monk <amonk@wikimedia.org>
|
|
* @file
|
|
* @ingroup Extensions
|
|
* @ingroup Maintenance
|
|
*/
|
|
|
|
require_once ( getenv( 'MW_INSTALL_PATH' ) !== false
|
|
? getenv( 'MW_INSTALL_PATH' ) . '/maintenance/Maintenance.php'
|
|
: __DIR__ . '/../../../maintenance/Maintenance.php' );
|
|
|
|
class VEAutodisablePref extends Maintenance {
|
|
public function __construct() {
|
|
parent::__construct();
|
|
$this->mDescription = "Sets the VisualEditor autodisable preference on appropriate users.";
|
|
$this->setBatchSize( 500 );
|
|
}
|
|
|
|
public function execute() {
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
$lastUserId = -1;
|
|
do {
|
|
$results = $dbr->select(
|
|
array( 'user', 'user_properties' ),
|
|
'user_id',
|
|
array(
|
|
'user_id > ' . $dbr->addQuotes( $lastUserId ),
|
|
'up_value IS NULL', // only select users with no entry in user_properties
|
|
'user_editcount > 0'
|
|
),
|
|
__METHOD__,
|
|
array(
|
|
'LIMIT' => $this->mBatchSize,
|
|
'ORDER BY' => 'user_id'
|
|
),
|
|
array(
|
|
'user_properties' => array(
|
|
'LEFT OUTER JOIN',
|
|
'user_id = up_user and up_property = "visualeditor-enable"'
|
|
)
|
|
)
|
|
);
|
|
foreach ( $results as $userRow ) {
|
|
$user = User::newFromId( $userRow->user_id );
|
|
$user->load( User::READ_LATEST );
|
|
$user->setOption( 'visualeditor-autodisable', true );
|
|
$user->saveSettings();
|
|
$lastUserId = $userRow->user_id;
|
|
}
|
|
$this->output( "Added preference for " . $results->numRows() . " users.\n" );
|
|
wfWaitForSlaves();
|
|
} while ( $results->numRows() == $this->mBatchSize );
|
|
$this->output( "done.\n" );
|
|
}
|
|
}
|
|
|
|
$maintClass = "VEAutodisablePref";
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|