X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FProtectionForm.php;h=51c29233852f7ae97e181ffe4027d19ae67b27ec;hb=f1907d3f012cf3ae4b56e256fb71cc04b5ec33ee;hp=71f4c415abe1958533afbf2d39ec3b84618b4bcc;hpb=ea23bc97ee9144c4575fa0bab81a42faa2b1f29c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index 71f4c415ab..51c2923385 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -183,21 +183,10 @@ class ProtectionForm { throw new ErrorPageError( 'protect-badnamespace-title', 'protect-badnamespace-text' ); } - $out = $this->mContext->getOutput(); - if ( !wfMessage( 'protect-dropdown' )->inContentLanguage()->isDisabled() ) { - $reasonsList = Xml::getArrayFromWikiTextList( - wfMessage( 'protect-dropdown' )->inContentLanguage()->text() - ); - $out->addModules( 'mediawiki.reasonSuggest' ); - $out->addJsConfigVars( [ - 'reasons' => $reasonsList - ] ); - } - if ( $this->mContext->getRequest()->wasPosted() ) { if ( $this->save() ) { $q = $this->mArticle->isRedirect() ? 'redirect=no' : ''; - $out->redirect( $this->mTitle->getFullURL( $q ) ); + $this->mContext->getOutput()->redirect( $this->mTitle->getFullURL( $q ) ); } } else { $this->show(); @@ -360,7 +349,9 @@ class ProtectionForm { $user = $context->getUser(); $output = $context->getOutput(); $lang = $context->getLanguage(); - $cascadingRestrictionLevels = $context->getConfig()->get( 'CascadingRestrictionLevels' ); + $conf = $context->getConfig(); + $cascadingRestrictionLevels = $conf->get( 'CascadingRestrictionLevels' ); + $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD; $out = ''; if ( !$this->disabled ) { $output->addModules( 'mediawiki.legacy.protect' ); @@ -505,6 +496,13 @@ class ProtectionForm { $this->mReasonSelection, 'mwProtect-reason', 4 ); + // 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 180 UTF-8 bytes for old schema). + // Subtract arbitrary 75 to leave some space for the autogenerated null edit's summary + // and other texts chosen by dropdown menus on this page. + $maxlength = $oldCommentSchema ? 180 : CommentStore::COMMENT_CHARACTER_LIMIT - 75; + $out .= Xml::openElement( 'table', [ 'id' => 'mw-protect-table3' ] ) . Xml::openElement( 'tbody' ); $out .= " @@ -522,10 +520,7 @@ class ProtectionForm { " . Xml::input( 'mwProtect-reason', 60, $this->mReason, [ 'type' => 'text', - 'id' => 'mwProtect-reason', 'maxlength' => 180 ] ) . - // Limited maxlength as the database trims at 255 bytes and other texts - // chosen by dropdown menus on this page are also included in this database field. - // The byte limit of 180 bytes is enforced in javascript + 'id' => 'mwProtect-reason', 'maxlength' => $maxlength ] ) . " "; # Disallow watching is user is not logged in @@ -627,7 +622,7 @@ class ProtectionForm { /** * Show protection long extracts for this page * - * @param OutputPage $out + * @param OutputPage &$out * @access private */ function showLogExtract( &$out ) {