Merge "API: Make jsonfm the default output format"
[lhc/web/wiklou.git] / includes / User.php
index 9897013..e6425f8 100644 (file)
@@ -1752,7 +1752,9 @@ class User implements IDBAccessObject {
                // If more than one group applies, use the group with the highest limit
                foreach ( $this->getGroups() as $group ) {
                        if ( isset( $limits[$group] ) ) {
-                               if ( $userLimit === false || $limits[$group] > $userLimit ) {
+                               if ( $userLimit === false
+                                       || $limits[$group][0] / $limits[$group][1] > $userLimit[0] / $userLimit[1]
+                               ) {
                                        $userLimit = $limits[$group];
                                }
                        }
@@ -2351,11 +2353,7 @@ class User implements IDBAccessObject {
                $this->setToken();
 
                $passwordFactory = self::getPasswordFactory();
-               if ( $str === null ) {
-                       $this->mPassword = $passwordFactory->newFromCiphertext( null );
-               } else {
-                       $this->mPassword = $passwordFactory->newFromPlaintext( $str );
-               }
+               $this->mPassword = $passwordFactory->newFromPlaintext( $str );
 
                $this->mNewpassword = $passwordFactory->newFromCiphertext( null );
                $this->mNewpassTime = null;
@@ -2400,14 +2398,11 @@ class User implements IDBAccessObject {
        public function setNewpassword( $str, $throttle = true ) {
                $this->loadPasswords();
 
+               $this->mNewpassword = self::getPasswordFactory()->newFromPlaintext( $str );
                if ( $str === null ) {
-                       $this->mNewpassword = '';
                        $this->mNewpassTime = null;
-               } else {
-                       $this->mNewpassword = self::getPasswordFactory()->newFromPlaintext( $str );
-                       if ( $throttle ) {
-                               $this->mNewpassTime = wfTimestampNow();
-                       }
+               } elseif ( $throttle ) {
+                       $this->mNewpassTime = wfTimestampNow();
                }
        }