r49932 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49931‎ | r49932 | r49933 >
Date:06:15, 27 April 2009
Author:werdna
Status:resolved
Tags:
Comment:
Partial revert of r49790 (global preferences) at Brion's request to ease review load (and there's at least an issue or two anyway).
Modified paths:
  • /trunk/extensions/CentralAuth/CentralAuth.i18n.php (modified) (history)
  • /trunk/extensions/CentralAuth/CentralAuth.php (modified) (history)
  • /trunk/extensions/CentralAuth/CentralAuthHooks.php (modified) (history)
  • /trunk/extensions/CentralAuth/CentralAuthUser.php (modified) (history)
  • /trunk/extensions/CentralAuth/central-auth.sql (modified) (history)
  • /trunk/extensions/CentralAuth/db_patches/patch-global_properties.sql (deleted) (history)

Diff [purge]

Index: trunk/extensions/CentralAuth/central-auth.sql
@@ -164,13 +164,3 @@
165165 PRIMARY KEY (ggr_group),
166166 KEY (ggr_set)
167167 ) /*$wgDBTableOptions*/;
168 -
169 -CREATE TABLE global_preferences (
170 - gp_user int(11) NOT NULL,
171 - gp_key varbinary(255) NOT NULL,
172 - gp_value BLOB,
173 -
174 - PRIMARY KEY (up_user,up_property),
175 - KEY (up_property)
176 -) /*$wgDBTableOptions*/;
Index: trunk/extensions/CentralAuth/db_patches/patch-global_properties.sql
@@ -1,9 +0,0 @@
2 -CREATE TABLE global_user_properties (
3 - gp_user int NOT NULL,
4 - gp_property varbinary(255) NOT NULL,
5 - gp_value BLOB,
6 -
7 - PRIMARY KEY (gp_user,gp_property),
8 - KEY (gp_property)
9 -) /*$wgDBTableOptions*/;
Index: trunk/extensions/CentralAuth/CentralAuthUser.php
@@ -18,7 +18,7 @@
1919 */
2020 /*private*/ var $mName;
2121 /*private*/ var $mStateDirty = false;
22 - /*private*/ var $mVersion = 3;
 22+ /*private*/ var $mVersion = 2;
2323 /*private*/ var $mDelayInvalidation = 0;
2424
2525 static $mCacheVars = array(
@@ -33,7 +33,6 @@
3434 'mAuthenticationTimestamp',
3535 'mGroups',
3636 'mRights',
37 - 'mProperties',
3837
3938 # Store the string list instead of the array, to save memory, and
4039 # avoid unserialize() overhead
@@ -90,11 +89,9 @@
9190 */
9291 protected function resetState() {
9392 unset( $this->mGlobalId );
94 - unset( $this->mProperties );
9593 unset( $this->mGroups );
9694 unset( $this->mAttachedArray );
9795 unset( $this->mAttachedList );
98 - unset( $this->mProperties );
9996 }
10097
10198 /**
@@ -192,89 +189,6 @@
193190 $this->mRights = $rights;
194191 $this->mGroups = array_keys($groups);
195192 }
196 -
197 - /**
198 - * Load user properties from the database.
199 - */
200 - protected function loadProperties() {
201 - if ( isset($this->mProperties) ) return;
202 -
203 - wfDebugLog( 'CentralAuth', "Loading properties for global user {$this->mName}" );
204 -
205 - $dbr = self::getCentralDB();
206 -
207 - $res = $dbr->select(
208 - 'global_user_properties', array( 'gp_property', 'gp_value' ),
209 - array( 'gp_user' => $this->getId() ), __METHOD__ );
210 -
211 - $properties = array();
212 -
213 - while( $row = $dbr->fetchObject( $res ) ) {
214 - $properties[$row->gp_property] = $row->gp_value;
215 - }
216 -
217 - $this->mProperties = $properties;
218 - }
219 -
220 - function saveProperties() {
221 - $this->loadProperties();
222 - $dbw = self::getCentralDB();
223 -
224 - $insert_rows = array();
225 -
226 - global $wgCentralAuthPropertySaveWhitelist;
227 - foreach( $this->mProperties as $key => $value ) {
228 - if ( ( is_null(User::getDefaultOption($key)) &&
229 - !( $value === false || is_null($value) ) ) ||
230 - $value != User::getDefaultOption( $key ) ||
231 - in_array( $key, $wgCentralAuthPropertySaveWhitelist ) ) {
232 - $insert_rows[] = array(
233 - 'gp_user' => $this->getId(),
234 - 'gp_property' => $key,
235 - 'gp_value' => $value,
236 - );
237 - }
238 - }
239 -
240 - $dbw->begin();
241 -
242 - $dbw->delete( 'global_user_properties',
243 - array( 'gp_user' => $this->getId() ),
244 - __METHOD__ );
245 - $dbw->insert( 'global_user_properties', $insert_rows, __METHOD__ );
246 -
247 - $dbw->commit();
248 -
249 - $this->invalidateCache();
250 - }
251 -
252 - function setProperty( $key, $value ) {
253 - $this->loadProperties();
254 - $this->mProperties[$key] = $value;
255 - $this->mStateDirty = true;
256 - }
257 -
258 - function setProperties( $properties, $method = 'replace' ) {
259 - $this->loadProperties();
260 - if ($method == 'replace') {
261 - $this->mProperties = $properties;
262 - } elseif ($method == 'insert') {
263 - $this->mProperties = array_merge( $this->mProperties, $properties );
264 - }
265 -
266 - $this->mStateDirty = true;
267 - }
268 -
269 - function getProperties() {
270 - $this->loadProperties();
271 - return $this->mProperties;
272 - }
273 -
274 - function getProperty( $name ) {
275 - $properties = $this->getProperties();
276 -
277 - return $properties[$name];
278 - }
279193
280194 /**
281195 * Load user state from a joined globaluser/localuser row
@@ -351,7 +265,6 @@
352266 $this->loadState();
353267 $this->loadAttached();
354268 $this->loadGroups();
355 - $this->loadProperties();
356269
357270 $obj = array();
358271 foreach( self::$mCacheVars as $var ) {
Index: trunk/extensions/CentralAuth/CentralAuth.php
@@ -126,12 +126,6 @@
127127 $wgCentralAuthUDPAddress = false;
128128 $wgCentralAuthNew2UDPPrefix = '';
129129
130 -/** Settings which will always be saved to the DB, regardless of whether or not they
131 - * match the local default. This should be mainly settings whose defaults change per-wiki.
132 - */
133 -$wgCentralAuthPropertySaveWhitelist =
134 - array( 'language', 'variant' );
135 -
136130 /**
137131 * Initialization of the autoloaders, and special extension pages.
138132 */
@@ -174,8 +168,6 @@
175169 $wgHooks['UserLoadDefaults'][] = 'CentralAuthHooks::onUserLoadDefaults';
176170 $wgHooks['getUserPermissionsErrorsExpensive'][] = 'CentralAuthHooks::onGetUserPermissionsErrorsExpensive';
177171 $wgHooks['MakeGlobalVariablesScript'][] = 'CentralAuthHooks::onMakeGlobalVariablesScript';
178 -$wgHooks['UserSaveOptions'][] = 'CentralAuthHooks::onSavePreferences';
179 -$wgHooks['UserLoadOptions'][] = 'CentralAuthHooks::onUserLoadOptions';
180172
181173 // For interaction with the Special:Renameuser extension
182174 $wgHooks['RenameUserWarning'][] = 'CentralAuthHooks::onRenameUserWarning';
@@ -223,8 +215,6 @@
224216 $wgLogActions['gblrights/groupprms3'] = 'centralauth-rightslog-entry-groupperms3';
225217 foreach( array( 'newset', 'setrename', 'setnewtype', 'setchange' ) as $type )
226218 $wgLogActionsHandlers["gblrights/{$type}"] = 'efHandleWikiSetLogEntry';
227 -
228 -$wgDefaultUserOptions['globalpreferences'] = true;
229219
230220 function efHandleWikiSetLogEntry( $type, $action, $title, $skin, $params, $filterWikilinks = false ) {
231221 wfLoadExtensionMessages('SpecialCentralAuth');
Index: trunk/extensions/CentralAuth/CentralAuthHooks.php
@@ -550,35 +550,4 @@
551551 }
552552 return true;
553553 }
554 -
555 - static function onSavePreferences( $user, &$preferences ) {
556 - $centralUser = CentralAuthUser::getInstance( $user );
557 -
558 - if ($centralUser->exists() && $centralUser->isAttached() &&
559 - !empty($preferences['globalpreferences']) ) {
560 - // Save preferences into the global account.
561 -
562 - $centralUser->setProperties( $preferences, 'replace' );
563 - $centralUser->saveProperties();
564 -
565 - $preferences = array( 'globalpreferences' => true );
566 -
567 - return true;
568 - }
569 -
570 - return true;
571 - }
572 -
573 - static function onUserLoadOptions( $user, &$preferences ) {
574 - $centralUser = CentralAuthUser::getInstance( $user );
575 - if ($centralUser->exists() && $centralUser->isAttached() &&
576 - !empty($preferences['globalpreferences']) ) {
577 - // Pull preferences from global account
578 -
579 - $preferences = array_merge( $preferences, $centralUser->getProperties() );
580 - $preferences['globalpreferences'] = true;
581 - }
582 -
583 - return true;
584 - }
585554 }
Index: trunk/extensions/CentralAuth/CentralAuth.i18n.php
@@ -196,7 +196,6 @@
197197 'centralauth-prefs-count-unattached' => 'Unconfirmed accounts with your name remain on $1 {{PLURAL:$1|project|projects}}.',
198198 'centralauth-prefs-detail-unattached' => 'This project site has not been confirmed as belonging to the global account.',
199199 'centralauth-prefs-manage' => 'Manage your global account',
200 - 'centralauth-prefs-global' => 'Use these preferences on all projects',
201200
202201 // Interaction with Special:Renameuser
203202 'centralauth-renameuser-merged' => "User $1 has been migrated to the unified login system.

Follow-up revisions

RevisionCommit summaryAuthorDate
r49958Fix reversion of global preferences by removing the relevant preference for g...werdna14:31, 27 April 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r49790Branch merge of preferences work branch. Includes fixes for several bugs. WAR...werdna01:31, 24 April 2009

Status & tagging log