r80910 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80909‎ | r80910 | r80911 >
Date:20:26, 24 January 2011
Author:catrope
Status:ok
Tags:
Comment:
1.16wmf4: Commit live hack to make global opt-out not melt the database. This code has been in here since late August but it still doesn't work properly
Modified paths:
  • /branches/wmf/1.16wmf4/extensions/UsabilityInitiative/PrefSwitch/SpecialPrefSwitch.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.16wmf4/extensions/UsabilityInitiative/PrefSwitch/SpecialPrefSwitch.php
@@ -85,6 +85,7 @@
8686 $globalUser->getName(),
8787 true
8888 );
 89+
8990 if ( $remoteUser ) {
9091 self::switchOffUser( $remoteUser );
9192 }
@@ -94,10 +95,23 @@
9596
9697 private static function switchOffUser( $user ) {
9798 global $wgPrefSwitchPrefs;
98 - foreach ( $wgPrefSwitchPrefs['off'] as $pref => $value ) {
 99+ // HACK check they don't already have a setting
 100+ $dbname = $user instanceof UserRightsProxy ? $user->getDBName() : false;
 101+ $dbw = wfGetDb( DB_MASTER, array(), $dbname );
 102+ $res = $dbw->select( 'user_properties', 'up_property', array( 'up_user' => $user->getID(), 'up_property' => array_keys( $wgPrefSwitchPrefs['off'] ) ), __METHOD__ );
 103+ $alreadySet = array();
 104+ foreach ( $res as $row ) {
 105+ $alreadySet[$row->up_property] = true;
 106+ }
 107+ foreach ( array_diff_key( $wgPrefSwitchPrefs['off'], $alreadySet ) as $pref => $value ) {
99108 $user->setOption( $pref, $value );
100109 }
101110 $user->saveSettings();
 111+ // HACK close the connection so s3 doesn't get overloaded
 112+ // but don't close the currnet wiki's connection
 113+ if ( $dbname ) {
 114+ $dbw->close();
 115+ }
102116 }
103117
104118 /* Functions */

Status & tagging log