Remove "editusercssjs" user right
[lhc/web/wiklou.git] / includes / user / User.php
index 0acdb55..e9f6dce 100644 (file)
@@ -146,7 +146,6 @@ class User implements IDBAccessObject {
                'editmyuserjs',
                'editmywatchlist',
                'editsemiprotected',
-               'editusercssjs', # deprecated
                'editusercss',
                'edituserjs',
                'hideuser',
@@ -1745,11 +1744,12 @@ class User implements IDBAccessObject {
                                        $this->blockTrigger = 'cookie-block';
                                        return $tmpBlock;
                                } else {
-                                       // If the block is not valid, clear the block cookie (but don't delete it,
-                                       // because it needs to be cleared from LocalStorage as well and an empty string
-                                       // value is checked for in the mediawiki.user.blockcookie module).
-                                       $tmpBlock->setCookie( $this->getRequest()->response(), true );
+                                       // If the block is not valid, remove the cookie.
+                                       Block::clearCookie( $this->getRequest()->response() );
                                }
+                       } else {
+                               // If the block doesn't exist, remove the cookie.
+                               Block::clearCookie( $this->getRequest()->response() );
                        }
                }
                return false;
@@ -3215,7 +3215,7 @@ class User implements IDBAccessObject {
 
        /**
         * Get the permissions this user has.
-        * @return array Array of String permission names
+        * @return string[] permission names
         */
        public function getRights() {
                if ( is_null( $this->mRights ) ) {
@@ -5265,6 +5265,13 @@ class User implements IDBAccessObject {
                                $this->mOptionOverrides = [];
                                $data = [];
                                foreach ( $res as $row ) {
+                                       // Convert '0' to 0. PHP's boolean conversion considers them both
+                                       // false, but e.g. JavaScript considers the former as true.
+                                       // @todo: T54542 Somehow determine the desired type (string/int/bool)
+                                       //  and convert all values here.
+                                       if ( $row->up_value === '0' ) {
+                                               $row->up_value = 0;
+                                       }
                                        $data[$row->up_property] = $row->up_value;
                                }
                        }