Merge "Add explanation about JS editing changes to permission error"
[lhc/web/wiklou.git] / includes / user / User.php
index 4e6e83a..5e57a18 100644 (file)
@@ -147,6 +147,9 @@ class User implements IDBAccessObject, UserIdentity {
                'editmyuserjs',
                'editmywatchlist',
                'editsemiprotected',
+               'editsitecss',
+               'editsitejson',
+               'editsitejs',
                'editusercss',
                'edituserjson',
                'edituserjs',
@@ -759,7 +762,8 @@ class User implements IDBAccessObject, UserIdentity {
         * will be loaded once more from the database when accessing them.
         *
         * @param stdClass $row A row from the user table
-        * @param array $data Further data to load into the object (see User::loadFromRow for valid keys)
+        * @param array|null $data Further data to load into the object
+        *  (see User::loadFromRow for valid keys)
         * @return User
         */
        public static function newFromRow( $row, $data = null ) {
@@ -1062,7 +1066,7 @@ class User implements IDBAccessObject, UserIdentity {
         * @param string|array $groups A single group name or an array of group names
         * @param int $limit Max number of users to return. The actual limit will never exceed 5000
         *   records; larger values are ignored.
-        * @param int $after ID the user to start after
+        * @param int|null $after ID the user to start after
         * @return UserArrayFromResult
         */
        public static function findUsersByGroup( $groups, $limit = 5000, $after = null ) {
@@ -1465,7 +1469,7 @@ class User implements IDBAccessObject, UserIdentity {
         * Initialize this object from a row from the user table.
         *
         * @param stdClass $row Row from the user table to load.
-        * @param array $data Further user data to load into the object
+        * @param array|null $data Further user data to load into the object
         *
         *  user_groups   Array of arrays or stdClass result rows out of the user_groups
         *                table. Previously you were supposed to pass an array of strings
@@ -2692,7 +2696,7 @@ class User implements IDBAccessObject, UserIdentity {
        /**
         * Update the 'You have new messages!' status.
         * @param bool $val Whether the user has new messages
-        * @param Revision $curRev New, as yet unseen revision of the user talk
+        * @param Revision|null $curRev New, as yet unseen revision of the user talk
         *   page. Ignored if null or !$val.
         */
        public function setNewtalk( $val, $curRev = null ) {
@@ -3133,7 +3137,7 @@ class User implements IDBAccessObject, UserIdentity {
         * Get the user's current setting for a given option.
         *
         * @param string $oname The option to check
-        * @param string|array $defaultOverride A default value returned if the option does not exist
+        * @param string|array|null $defaultOverride A default value returned if the option does not exist
         * @param bool $ignoreHidden Whether to ignore the effects of $wgHiddenPrefs
         * @return string|array|int|null User's current value for the option
         * @see getBoolOption()
@@ -3328,7 +3332,7 @@ class User implements IDBAccessObject, UserIdentity {
         *
         * @see User::listOptionKinds
         * @param IContextSource $context
-        * @param array $options Assoc. array with options keys to check as keys.
+        * @param array|null $options Assoc. array with options keys to check as keys.
         *   Defaults to $this->mOptions.
         * @return array The key => kind mapping data
         */
@@ -3690,7 +3694,7 @@ class User implements IDBAccessObject, UserIdentity {
         * never expire.)
         *
         * @param string $group Name of the group to add
-        * @param string $expiry Optional expiry timestamp in any format acceptable to
+        * @param string|null $expiry Optional expiry timestamp in any format acceptable to
         *   wfTimestamp(), or null if the group assignment should not expire
         * @return bool
         */
@@ -4068,7 +4072,7 @@ class User implements IDBAccessObject, UserIdentity {
         *
         * @param WebRequest|null $request WebRequest object to use; $wgRequest will be used if null
         *        is passed.
-        * @param bool $secure Whether to force secure/insecure cookies or use default
+        * @param bool|null $secure Whether to force secure/insecure cookies or use default
         * @param bool $rememberMe Whether to add a Token cookie for elongated sessions
         */
        public function setCookies( $request = null, $secure = null, $rememberMe = false ) {
@@ -4617,7 +4621,7 @@ class User implements IDBAccessObject, UserIdentity {
         * @param string $val Input value to compare
         * @param string|array $salt Optional function-specific data for hashing
         * @param WebRequest|null $request Object to use or null to use $wgRequest
-        * @param int $maxage Fail tokens older than this, in seconds
+        * @param int|null $maxage Fail tokens older than this, in seconds
         * @return bool Whether the token matches
         */
        public function matchEditToken( $val, $salt = '', $request = null, $maxage = null ) {
@@ -4631,7 +4635,7 @@ class User implements IDBAccessObject, UserIdentity {
         * @param string $val Input value to compare
         * @param string|array $salt Optional function-specific data for hashing
         * @param WebRequest|null $request Object to use or null to use $wgRequest
-        * @param int $maxage Fail tokens older than this, in seconds
+        * @param int|null $maxage Fail tokens older than this, in seconds
         * @return bool Whether the token matches
         */
        public function matchEditTokenNoSuffix( $val, $salt = '', $request = null, $maxage = null ) {
@@ -4682,7 +4686,7 @@ class User implements IDBAccessObject, UserIdentity {
         * @param string $body Message body
         * @param User|null $from Optional sending user; if unspecified, default
         *   $wgPasswordSender will be used.
-        * @param string $replyto Reply-To address
+        * @param string|null $replyto Reply-To address
         * @return Status
         */
        public function sendMail( $subject, $body, $from = null, $replyto = null ) {
@@ -5069,10 +5073,10 @@ class User implements IDBAccessObject, UserIdentity {
         */
        public static function getAllGroups() {
                global $wgGroupPermissions, $wgRevokePermissions;
-               return array_diff(
+               return array_values( array_diff(
                        array_merge( array_keys( $wgGroupPermissions ), array_keys( $wgRevokePermissions ) ),
                        self::getImplicitGroups()
-               );
+               ) );
        }
 
        /**
@@ -5446,7 +5450,7 @@ class User implements IDBAccessObject, UserIdentity {
        /**
         * Load the user options either from cache, the database or an array
         *
-        * @param array $data Rows for the current user out of the user_properties table
+        * @param array|null $data Rows for the current user out of the user_properties table
         */
        protected function loadOptions( $data = null ) {
                global $wgContLang;
@@ -5506,12 +5510,6 @@ class User implements IDBAccessObject, UserIdentity {
                                }
                        }
 
-                       // Convert the email blacklist from a new line delimited string
-                       // to an array of ids.
-                       if ( isset( $data['email-blacklist'] ) && $data['email-blacklist'] ) {
-                               $data['email-blacklist'] = array_map( 'intval', explode( "\n", $data['email-blacklist'] ) );
-                       }
-
                        foreach ( $data as $property => $value ) {
                                $this->mOptionOverrides[$property] = $value;
                                $this->mOptions[$property] = $value;
@@ -5539,26 +5537,6 @@ class User implements IDBAccessObject, UserIdentity {
                // Not using getOptions(), to keep hidden preferences in database
                $saveOptions = $this->mOptions;
 
-               // Convert usernames to ids.
-               if ( isset( $this->mOptions['email-blacklist'] ) ) {
-                       if ( $this->mOptions['email-blacklist'] ) {
-                               $value = $this->mOptions['email-blacklist'];
-                               // Email Blacklist may be an array of ids or a string of new line
-                               // delimnated user names.
-                               if ( is_array( $value ) ) {
-                                       $ids = array_filter( $value, 'is_numeric' );
-                               } else {
-                                       $lookup = CentralIdLookup::factory();
-                                       $ids = $lookup->centralIdsFromNames( explode( "\n", $value ), $this );
-                               }
-                               $this->mOptions['email-blacklist'] = $ids;
-                               $saveOptions['email-blacklist'] = implode( "\n", $this->mOptions['email-blacklist'] );
-                       } else {
-                               // If the blacklist is empty, set it to null rather than an empty string.
-                               $this->mOptions['email-blacklist'] = null;
-                       }
-               }
-
                // Allow hooks to abort, for instance to save to a global profile.
                // Reset options to default state before saving.
                if ( !Hooks::run( 'UserSaveOptions', [ $this, &$saveOptions ] ) ) {