Add a hook to smoothly deal with old user preferences during migration

Catches people who have opted out of old style talk page notifications and opts them out
of equivalent new ones.
Needs $wgRecentEchoInstall = true in LocalSettings.php so it can be turned off when no
longer needed.

The migration has 1 million rows to write on enwiki so will take some time

Change-Id: Ie6201df378bf8df813b3d461ea9a8521d99b1bb9
This commit is contained in:
lwelling 2013-04-26 12:08:40 -04:00
parent 76abac53c5
commit 069249cd62
2 changed files with 27 additions and 0 deletions

View file

@ -104,6 +104,8 @@ $echoResourceTemplate = array(
'group' => 'ext.echo',
);
$wgRecentEchoInstall = false; // default should be overridden with true until sure migration is complete
$wgResourceModules += array(
'ext.echo.base' => $echoResourceTemplate + array(
'styles' => 'base/ext.echo.base.css',

View file

@ -730,4 +730,29 @@ class EchoHooks {
EchoNotificationController::resetNotificationCount( $user );
return true;
}
/**
* Handler for UserLoadOptions hook.
* @see http://www.mediawiki.org/wiki/Manual:Hooks/UserLoadOptions
* @param $user User whose options were loaded
* @param $options Options can be modified
* @return bool true in all cases
*/
public static function onUserLoadOptions( $user, &$options ) {
// If the user had opted out of the old version of talk page notification emails
// but we have not migrated a new style preference for the same preference
// then fake a new style one too
// Only check while we are migrating
global $wgRecentEchoInstall;
if ( $wgRecentEchoInstall ) {
if ( isset( $options['enotifusertalkpages'] ) &&
!$options['enotifusertalkpages']
) {
$options['echo-subscriptions-email-edit-user-talk'] = false;
}
}
// note not calling saveSettings()
// so will not change on disk until user saves for some other reason
return true;
}
}