From: Aaron Schulz Date: Mon, 30 Mar 2015 19:00:07 +0000 (-0700) Subject: Added read-only checks around User::saveSettings where they belong X-Git-Tag: 1.31.0-rc.0~11874^2 X-Git-Url: https://git.heureux-cyclage.org/?a=commitdiff_plain;ds=sidebyside;h=f7fe3c2b46d3e0ec7f30f3efe722ce0316454d1f;p=lhc%2Fweb%2Fwiklou.git Added read-only checks around User::saveSettings where they belong * Ideally saveSettings() would not just silently do nothing in read-only mode as not all callers expect that behavior. This change is just the first step. Change-Id: Ieeaf531dac3027ddba89c60159b98f9c04de78d3 --- diff --git a/includes/User.php b/includes/User.php index 2e88978110..322f8af5ec 100644 --- a/includes/User.php +++ b/includes/User.php @@ -2706,7 +2706,9 @@ class User implements IDBAccessObject { $token = $this->getOption( $oname ); if ( !$token ) { $token = $this->resetTokenFromOption( $oname ); - $this->saveSettings(); + if ( !wfReadOnly() ) { + $this->saveSettings(); + } } return $token; } @@ -3500,7 +3502,9 @@ class User implements IDBAccessObject { // Simply by setting every cell in the user_token column to NULL and letting them be // regenerated as users log back into the wiki. $this->setToken(); - $this->saveSettings(); + if ( !wfReadOnly() ) { + $this->saveSettings(); + } } $session = array( 'wsUserID' => $this->mId, @@ -3581,11 +3585,12 @@ class User implements IDBAccessObject { public function saveSettings() { global $wgAuth; - $this->load(); - $this->loadPasswords(); if ( wfReadOnly() ) { return; // @TODO: caller should deal with this instead! } + + $this->load(); + $this->loadPasswords(); if ( 0 == $this->mId ) { return; } @@ -3939,7 +3944,7 @@ class User implements IDBAccessObject { } $passwordFactory = self::getPasswordFactory(); - if ( $passwordFactory->needsUpdate( $this->mPassword ) ) { + if ( $passwordFactory->needsUpdate( $this->mPassword ) && !wfReadOnly() ) { $this->mPassword = $passwordFactory->newFromPlaintext( $password ); $this->saveSettings(); } diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 55be2c2b34..608d62e63e 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -533,7 +533,7 @@ class SpecialSearch extends SpecialPage { $request->getVal( 'nsRemember' ), 'searchnamespace', $request - ) + ) && !wfReadOnly() ) { // Reset namespace preferences: namespaces are not searched // when they're not mentioned in the URL parameters. diff --git a/includes/specials/SpecialUserlogin.php b/includes/specials/SpecialUserlogin.php index d6634a83c0..10edbcfb9e 100644 --- a/includes/specials/SpecialUserlogin.php +++ b/includes/specials/SpecialUserlogin.php @@ -762,7 +762,7 @@ class LoginForm extends SpecialPage { // As a side-effect, we can authenticate the user's e-mail ad- // dress if it's not already done, since the temporary password // was sent via e-mail. - if ( !$u->isEmailConfirmed() ) { + if ( !$u->isEmailConfirmed() && !wfReadOnly() ) { $u->confirmEmail(); $u->saveSettings(); }