From 043a9087464a4f1e3346a317342111e56a23f5f3 Mon Sep 17 00:00:00 2001 From: Thalia Date: Mon, 14 Jan 2019 14:58:42 +0000 Subject: [PATCH] Fix non-editing partial block creation on Special:Block Bug: T213707 Change-Id: Iaf8b3a6a0b2715808c9e6f8de94d315404368b12 --- includes/specials/SpecialBlock.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index 47d61b82a0..e47ef0619c 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -399,6 +399,10 @@ class SpecialBlock extends FormSpecialPage { $pageRestrictions[] = $restriction->getTitle()->getPrefixedText(); } + if ( !$block->isSitewide() && empty( $pageRestrictions ) ) { + $fields['Editing']['default'] = false; + } + // Sort the restrictions so they are in alphabetical order. sort( $pageRestrictions ); $fields['PageRestrictions']['default'] = implode( "\n", $pageRestrictions ); @@ -1158,6 +1162,12 @@ class SpecialBlock extends FormSpecialPage { * @return bool|array True for success, false for didn't-try, array of errors on failure */ public function onSubmit( array $data, HTMLForm $form = null ) { + // If "Editing" checkbox is unchecked, the block must be a partial block affecting + // actions other than editing, and there must be no restrictions. + if ( isset( $data['Editing'] ) && $data['Editing'] === false ) { + $data['EditingRestriction'] = 'partial'; + $data['PageRestrictions'] = []; + } return self::processForm( $data, $form->getContext() ); } -- 2.20.1