diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2011-12-03 13:29:22 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2011-12-03 13:29:22 +0100 |
commit | ca32f08966f1b51fcb19460f0996bb0c4048e6fe (patch) | |
tree | ec04cc15b867bc21eedca904cea9af0254531a11 /extensions/Vector/switchExperimentPrefs.php | |
parent | a22fbfc60f36f5f7ee10d5ae6fe347340c2ee67c (diff) |
Update to MediaWiki 1.18.0
* also update ArchLinux skin to chagnes in MonoBook
* Use only css to hide our menu bar when printing
Diffstat (limited to 'extensions/Vector/switchExperimentPrefs.php')
-rw-r--r-- | extensions/Vector/switchExperimentPrefs.php | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/extensions/Vector/switchExperimentPrefs.php b/extensions/Vector/switchExperimentPrefs.php new file mode 100644 index 00000000..82ddd868 --- /dev/null +++ b/extensions/Vector/switchExperimentPrefs.php @@ -0,0 +1,63 @@ +<?php + +$path = '../..'; + +if ( getenv( 'MW_INSTALL_PATH' ) !== false ) { + $path = getenv( 'MW_INSTALL_PATH' ); +} + +require_once( $path . '/maintenance/Maintenance.php' ); + +class SwitchExperimentPrefs extends Maintenance { + function __construct() { + parent::__construct(); + $this->addOption( 'pref', 'Preference to set', true, true ); + $this->addOption( 'value', 'Value to set the preference to', true, true ); + $this->mDescription = 'Set a preference for all users that have the vector-noexperiments preference enabled.'; + } + + function execute() { + $dbw = wfGetDB( DB_MASTER ); + + $batchSize = 100; + $total = 0; + $lastUserID = 0; + while ( true ) { + $res = $dbw->select( 'user_properties', array( 'up_user' ), + array( 'up_property' => 'vector-noexperiments', "up_user > $lastUserID" ), + __METHOD__, + array( 'LIMIT' => $batchSize ) ); + if ( !$res->numRows() ) { + $dbw->commit(); + break; + } + $total += $res->numRows(); + + $ids = array(); + foreach ( $res as $row ) { + $ids[] = $row->up_user; + } + $lastUserID = max( $ids ); + + + foreach ( $ids as $id ) { + $user = User::newFromId( $id ); + if ( !$user->isLoggedIn() ) + continue; + $user->setOption( $this->getOption( 'pref' ), $this->getOption( 'value' ) ); + $user->saveSettings(); + } + + echo "$total\n"; + + wfWaitForSlaves(); // Must be wfWaitForSlaves_masterPos(); on 1.17wmf1 + } + echo "Done\n"; + + } +} + +$maintClass = 'SwitchExperimentPrefs'; +require_once( RUN_MAINTENANCE_IF_MAIN ); + + |