Avoid DBPerformance log warnings in SpecialPreferences
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 14 Apr 2016 23:22:54 +0000 (16:22 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 14 Apr 2016 23:22:54 +0000 (16:22 -0700)
Preference views do not need the master DB.

Change-Id: Id0c3fc6d453b6af0eca8450107da6d554c822347

includes/specials/SpecialPreferences.php

index 7f257e6..2e7b4cd 100644 (file)
@@ -74,7 +74,11 @@ class SpecialPreferences extends SpecialPage {
                $this->addHelpLink( 'Help:Preferences' );
 
                // Load the user from the master to reduce CAS errors on double post (T95839)
-               $user = $this->getUser()->getInstanceForUpdate() ?: $this->getUser();
+               if ( $this->getRequest()->wasPosted() ) {
+                       $user = $this->getUser()->getInstanceForUpdate() ?: $this->getUser();
+               } else {
+                       $user = $this->getUser();
+               }
 
                $htmlForm = Preferences::getFormObject( $user, $this->getContext() );
                $htmlForm->setSubmitCallback( [ 'Preferences', 'tryUISubmit' ] );