http://www.mediawiki.org/wiki/Special:Code/MediaWiki/70570
Revision: 70570
Author: catrope
Date: 2010-08-06 14:51:16 +0000 (Fri, 06 Aug 2010)
Log Message:
-----------
DontSwitchMeOVer: Add maintenance script to take people back
Modified Paths:
--------------
trunk/extensions/UsabilityInitiative/DontSwitchMeOver/DontSwitchMeOver.php
Added Paths:
-----------
trunk/extensions/UsabilityInitiative/DontSwitchMeOver/post-switchover.php
Modified:
trunk/extensions/UsabilityInitiative/DontSwitchMeOver/DontSwitchMeOver.php
===================================================================
--- trunk/extensions/UsabilityInitiative/DontSwitchMeOver/DontSwitchMeOver.php
2010-08-06 14:12:41 UTC (rev 70569)
+++ trunk/extensions/UsabilityInitiative/DontSwitchMeOver/DontSwitchMeOver.php
2010-08-06 14:51:16 UTC (rev 70570)
@@ -19,7 +19,15 @@
*/
/* Configuration */
-
+
+// Preferences to switch back to. This has to be set because the old default
+// skin isn't remembered after a switchover.
+// You can also add more preferences here, and on wikis with PrefSwitch setting
+// $wgDontSwitchMeOverPrefs = $wgPrefSwitchPrefs['off']; is probably wise
+$wgDontSwitchMeOverPrefs = array(
+ 'skin' => 'monobook'
+);
+
// Credits
$wgExtensionCredits['other'][] = array(
'path' => __FILE__,
Added: trunk/extensions/UsabilityInitiative/DontSwitchMeOver/post-switchover.php
===================================================================
--- trunk/extensions/UsabilityInitiative/DontSwitchMeOver/post-switchover.php
(rev 0)
+++ trunk/extensions/UsabilityInitiative/DontSwitchMeOver/post-switchover.php
2010-08-06 14:51:16 UTC (rev 70570)
@@ -0,0 +1,60 @@
+<?php
+
+$IP = getenv( 'MW_INSTALL_PATH' );
+if ( $IP === false ) {
+ $IP = dirname( __FILE__ ) . '/../..';
+}
+require( "$IP/maintenance/Maintenance.php" );
+
+class PostSwitchover extends Maintenance {
+ const REPORTING_INTERVAL = 1000;
+
+ public function __construct() {
+ parent::__construct();
+ $this->mDescription = "Migrate users that indicated they didn't
want to be switched over back to the old defaults.";
+ $this->addArg( 'start', "User ID to start from. Use this to
resume an aborted run", false );
+ $this->addOption( 'maxlag', 'Maximum database slave lag in
seconds (5 by default)', false, true );
+ }
+
+ public function execute() {
+ $start = intval( $this->getOption( 'start', 0 ) );
+ $maxlag = intval( $this->getOption( 'maxlag', 5 ) );
+
+ $dbr = wfGetDb( DB_SLAVE );
+ $maxUserID = $dbr->selectField( 'user', 'MAX(user_id)', false );
+
+ $this->output( "Starting from user_id $start of $maxUserID\n" );
+ for ( $i = $start; $i < $maxUserID; $i++ ) {
+ $this->fixUser( $i );
+ if ( $i % self::REPORTING_INTERVAL == 0 ) {
+ $this->output( "$i\n" );
+ wfWaitForSlaves( $maxlag );
+ }
+ }
+ $this->output( "All done\n" );
+ }
+
+ private function fixUser( $i ) {
+ global $wgDontSwitchMeOverPrefs;
+ $user = User::newFromId( $i );
+
+ // If the user doesn't exist or doesn't have our preference
enabled, skip
+ if ( $user->isAnon() || !$user->getOption( 'dontswitchmeover' )
) {
+ return;
+ }
+
+ $changed = false;
+ foreach ( $wgDontSwitchMeOverPrefs as $pref => $oldVal ) {
+ if ( $user->getOption( $pref ) ==
User::getDefaultOption( $pref ) ) {
+ $user->setOption( $pref, $oldVal );
+ $changed = true;
+ }
+ }
+ if ( $changed ) {
+ $user->saveSettings();
+ }
+ }
+}
+
+$maintClass = "PostSwitchover";
+require_once( DO_MAINTENANCE );
Property changes on:
trunk/extensions/UsabilityInitiative/DontSwitchMeOver/post-switchover.php
___________________________________________________________________
Added: svn:eol-style
+ native
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs