Merge "build: Alter jscs rule 'requireDotNotation' to reflect need for ES3 compatibility"
[lhc/web/wiklou.git] / includes / User.php
index 4c044bd..da8ff79 100644 (file)
@@ -519,19 +519,24 @@ class User implements IDBAccessObject {
         * If the code is invalid or has expired, returns NULL.
         *
         * @param string $code Confirmation code
+        * @param int $flags User::READ_* bitfield
         * @return User|null
         */
-       public static function newFromConfirmationCode( $code ) {
-               $dbr = wfGetDB( DB_SLAVE );
-               $id = $dbr->selectField( 'user', 'user_id', array(
-                       'user_email_token' => md5( $code ),
-                       'user_email_token_expires > ' . $dbr->addQuotes( $dbr->timestamp() ),
-                       ) );
-               if ( $id !== false ) {
-                       return User::newFromId( $id );
-               } else {
-                       return null;
-               }
+       public static function newFromConfirmationCode( $code, $flags = 0 ) {
+               $db = ( $flags & self::READ_LATEST ) == self::READ_LATEST
+                       ? wfGetDB( DB_MASTER )
+                       : wfGetDB( DB_SLAVE );
+
+               $id = $db->selectField(
+                       'user',
+                       'user_id',
+                       array(
+                               'user_email_token' => md5( $code ),
+                               'user_email_token_expires > ' . $db->addQuotes( $db->timestamp() ),
+                       )
+               );
+
+               return $id ? User::newFromId( $id ) : null;
        }
 
        /**
@@ -3203,10 +3208,10 @@ class User implements IDBAccessObject {
        /**
         * Check if user is allowed to access a feature / make an action
         *
-        * @param string $permissions,... Permissions to test
+        * @param string ... Permissions to test
         * @return bool True if user is allowed to perform *any* of the given actions
         */
-       public function isAllowedAny( /*...*/ ) {
+       public function isAllowedAny() {
                $permissions = func_get_args();
                foreach ( $permissions as $permission ) {
                        if ( $this->isAllowed( $permission ) ) {
@@ -3218,10 +3223,10 @@ class User implements IDBAccessObject {
 
        /**
         *
-        * @param string $permissions,... Permissions to test
+        * @param string ... Permissions to test
         * @return bool True if the user is allowed to perform *all* of the given actions
         */
-       public function isAllowedAll( /*...*/ ) {
+       public function isAllowedAll() {
                $permissions = func_get_args();
                foreach ( $permissions as $permission ) {
                        if ( !$this->isAllowed( $permission ) ) {
@@ -3454,7 +3459,7 @@ class User implements IDBAccessObject {
                        $dbw = wfGetDB( DB_MASTER );
                        $dbw->update( 'watchlist',
                                array( /* SET */ 'wl_notificationtimestamp' => null ),
-                               array( /* WHERE */ 'wl_user' => $id ),
+                               array( /* WHERE */ 'wl_user' => $id, 'wl_notificationtimestamp IS NOT NULL' ),
                                __METHOD__
                        );
                        // We also need to clear here the "you have new message" notification for the own user_talk page;
@@ -3689,7 +3694,7 @@ class User implements IDBAccessObject {
                        $from = ( $this->queryFlagsUsed & self::READ_LATEST ) ? 'master' : 'slave';
                        throw new MWException(
                                "CAS update failed on user_touched for user ID '{$this->mId}' (read from $from);" .
-                               "the version of the user to be saved is older than the current version."
+                               " the version of the user to be saved is older than the current version."
                        );
                }