Merge "Revert "Log the reason why revision->getContent() returns null""
[lhc/web/wiklou.git] / includes / specials / SpecialUserrights.php
index e62731f..40f02a5 100644 (file)
@@ -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>