Defer preferences update and avoid CAS errors in onUserLoggedIn()

Bug: T143367
Change-Id: I9509f6ef565d9953f9c05b00b02b57098eef9e3a
This commit is contained in:
Aaron Schulz 2016-08-18 16:11:38 -07:00
parent 7660980ab5
commit 5f8dfc4b8f

View file

@ -1009,9 +1009,17 @@ class VisualEditorHooks {
public static function onUserLoggedIn( $user ) { public static function onUserLoggedIn( $user ) {
$cookie = RequestContext::getMain()->getRequest()->getCookie( 'VEE', '' ); $cookie = RequestContext::getMain()->getRequest()->getCookie( 'VEE', '' );
if ( $cookie === 'visualeditor' || $cookie === 'wikitext' ) { if ( $cookie === 'visualeditor' || $cookie === 'wikitext' ) {
$user->setOption( 'visualeditor-editor', $cookie ); DeferredUpdates::addUpdate( new AtomicSectionUpdate(
$user->saveSettings(); wfGetDB( DB_MASTER ),
__METHOD__,
function () use ( $user, $cookie ) {
$uLatest = $user->getInstanceForUpdate();
$uLatest->setOption( 'visualeditor-editor', $cookie );
$uLatest->saveSettings();
} }
) );
}
return true; return true;
} }
} }