userrights: Add array typehints to SpecialUserrights methods
[lhc/web/wiklou.git] / includes / specials / SpecialUserrights.php
index e62731f..6d6bf0e 100644 (file)
@@ -325,8 +325,8 @@ class UserrightsPage extends SpecialPage {
         *   containing only those groups that are to have new expiry values set
         * @return array Tuple of added, then removed groups
         */
-       function doSaveUserGroups( $user, $add, $remove, $reason = '', $tags = [],
-               $groupExpiries = []
+       function doSaveUserGroups( $user, array $add, array $remove, $reason = '',
+               array $tags = [], array $groupExpiries = []
        ) {
                // Validate input set...
                $isself = $user->getName() == $this->getUser()->getName();
@@ -427,13 +427,13 @@ class UserrightsPage extends SpecialPage {
         * @param User|UserRightsProxy $user
         * @param array $oldGroups
         * @param array $newGroups
-        * @param array $reason
+        * @param string $reason
         * @param array $tags Change tags for the log entry
         * @param array $oldUGMs Associative array of (group name => UserGroupMembership)
         * @param array $newUGMs Associative array of (group name => UserGroupMembership)
         */
-       protected function addLogEntry( $user, $oldGroups, $newGroups, $reason, $tags,
-               $oldUGMs, $newUGMs
+       protected function addLogEntry( $user, array $oldGroups, array $newGroups, $reason,
+               array $tags, array $oldUGMs, array $newUGMs
        ) {
                // make sure $oldUGMs and $newUGMs are in the same order, and serialise
                // each UGM object to a simplified array
@@ -716,6 +716,8 @@ class UserrightsPage extends SpecialPage {
                                ->rawParams( $userToolLinks )->parse()
                );
                if ( $canChangeAny ) {
+                       $conf = $this->getConfig();
+                       $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD;
                        $this->getOutput()->addHTML(
                                $this->msg( 'userrights-groups-help', $user->getName() )->parse() .
                                $grouplist .
@@ -726,8 +728,13 @@ class UserrightsPage extends SpecialPage {
                                                        Xml::label( $this->msg( 'userrights-reason' )->text(), 'wpReason' ) .
                                                "</td>
                                                <td class='mw-input'>" .
-                                                       Xml::input( 'user-reason', 60, $this->getRequest()->getVal( 'user-reason', false ),
-                                                               [ 'id' => 'wpReason', 'maxlength' => 255 ] ) .
+                                                       Xml::input( 'user-reason', 60, $this->getRequest()->getVal( 'user-reason', false ), [
+                                                               'id' => 'wpReason',
+                                                               // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
+                                                               // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
+                                                               // Unicode codepoints (or 255 UTF-8 bytes for old schema).
+                                                               'maxlength' => $oldCommentSchema ? 255 : CommentStore::COMMENT_CHARACTER_LIMIT,
+                                                       ] ) .
                                                "</td>
                                        </tr>
                                        <tr>