X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FProtectionForm.php;h=0d0654e8fa894544fd0c3805fc5cac1fd69d7040;hb=1ee582b2a867207a95e3e4d3ff11ea814e216cdd;hp=53608e849a39eb720f3c155c09ca4682f81b73e8;hpb=2480aae0c97d822e10b50619e7b48b25c45af073;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index 53608e849a..0d0654e8fa 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -196,7 +196,7 @@ class ProtectionForm { /** * Show the input form with optional error message * - * @param string $err Error message or null if there's no error + * @param string|null $err Error message or null if there's no error */ function show( $err = null ) { $out = $this->mContext->getOutput(); @@ -204,9 +204,9 @@ class ProtectionForm { $out->addBacklinkSubtitle( $this->mTitle ); if ( is_array( $err ) ) { - $out->wrapWikiMsg( "

\n$1\n

\n", $err ); + $out->wrapWikiMsg( "
\n$1\n
\n", $err ); } elseif ( is_string( $err ) ) { - $out->addHTML( "

{$err}

\n" ); + $out->addHTML( "
{$err}
\n" ); } if ( $this->mTitle->getRestrictionTypes() === [] ) { @@ -216,7 +216,9 @@ class ProtectionForm { 'protect-norestrictiontypes-title', $this->mTitle->getPrefixedText() ) ); - $out->addWikiText( $this->mContext->msg( 'protect-norestrictiontypes-text' )->plain() ); + $out->addWikiTextAsInterface( + $this->mContext->msg( 'protect-norestrictiontypes-text' )->plain() + ); // Show the log in case protection was possible once $this->showLogExtract( $out ); @@ -246,7 +248,9 @@ class ProtectionForm { $this->mContext->msg( 'protect-title-notallowed', $this->mTitle->getPrefixedText() ) ); - $out->addWikiText( $out->formatPermissionsErrorMessage( $this->mPermErrors, 'protect' ) ); + $out->addWikiTextAsInterface( $out->formatPermissionsErrorMessage( + $this->mPermErrors, 'protect' + ) ); } else { $out->setPageTitle( $this->mContext->msg( 'protect-title', $this->mTitle->getPrefixedText() ) ); $out->addWikiMsg( 'protect-text', @@ -349,7 +353,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' ); @@ -494,6 +500,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 .= " @@ -511,10 +524,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