X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialBlock.php;h=efe354a3465b06ddcc627caf2f26252857d43b2c;hb=478a58f63101f2b47d18a618296b5e7970fa3f24;hp=42e7040d0e5638b5be7e8095caee879b9f2311ce;hpb=949dc920ee61e838320186565cb6dc146a013b25;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index 42e7040d0e..efe354a346 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -135,6 +135,9 @@ class SpecialBlock extends FormSpecialPage { $suggestedDurations = self::getSuggestedDurations(); + $conf = $this->getConfig(); + $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD; + $a = [ 'Target' => [ 'type' => 'user', @@ -148,16 +151,19 @@ class SpecialBlock extends FormSpecialPage { 'validation-callback' => [ __CLASS__, 'validateTargetField' ], ], 'Expiry' => [ - 'type' => !count( $suggestedDurations ) ? 'text' : 'selectorother', + 'type' => 'expiry', 'label-message' => 'ipbexpiry', 'required' => true, 'options' => $suggestedDurations, - 'other' => $this->msg( 'ipbother' )->text(), 'default' => $this->msg( 'ipb-default-expiry' )->inContentLanguage()->text(), ], 'Reason' => [ 'type' => 'selectandother', - 'maxlength' => 255, + // 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, + 'maxlength-unit' => 'codepoints', 'label-message' => 'ipbreason', 'options-message' => 'ipbreason-dropdown', ], @@ -869,29 +875,38 @@ class SpecialBlock extends FormSpecialPage { $a[$show] = $value; } + if ( $a ) { + // if options exist, add other to the end instead of the begining (which + // is what happens by default). + $a[ wfMessage( 'ipbother' )->text() ] = 'other'; + } + return $a; } /** * Convert a submitted expiry time, which may be relative ("2 weeks", etc) or absolute * ("24 May 2034", etc), into an absolute timestamp we can put into the database. + * + * @todo strtotime() only accepts English strings. This means the expiry input + * can only be specified in English. + * @see https://secure.php.net/manual/en/function.strtotime.php + * * @param string $expiry Whatever was typed into the form - * @return string Timestamp or 'infinity' + * @return string|bool Timestamp or 'infinity' or false on error. */ public static function parseExpiryInput( $expiry ) { if ( wfIsInfinity( $expiry ) ) { - $expiry = 'infinity'; - } else { - $expiry = strtotime( $expiry ); + return 'infinity'; + } - if ( $expiry < 0 || $expiry === false ) { - return false; - } + $expiry = strtotime( $expiry ); - $expiry = wfTimestamp( TS_MW, $expiry ); + if ( $expiry < 0 || $expiry === false ) { + return false; } - return $expiry; + return wfTimestamp( TS_MW, $expiry ); } /**