Merge "Fix SpecialBlock validation for ipb_allow_usertalk"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 31 Jul 2019 12:36:45 +0000 (12:36 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 31 Jul 2019 12:36:45 +0000 (12:36 +0000)
1  2 
includes/specials/SpecialBlock.php
languages/i18n/en.json
languages/i18n/qqq.json

@@@ -754,8 -754,6 +754,6 @@@ class SpecialBlock extends FormSpecialP
         * @return bool|array
         */
        public static function processForm( array $data, IContextSource $context ) {
-               global $wgBlockAllowsUTEdit, $wgHideUserContribLimit;
                $performer = $context->getUser();
                $enablePartialBlocks = $context->getConfig()->get( 'EnablePartialBlocks' );
                $isPartialBlock = $enablePartialBlocks &&
                        }
  
                        # Recheck params here...
+                       $hideUserContribLimit = $context->getConfig()->get( 'HideUserContribLimit' );
                        if ( $type != DatabaseBlock::TYPE_USER ) {
                                $data['HideUser'] = false; # IP users should not be hidden
                        } elseif ( !wfIsInfinity( $data['Expiry'] ) ) {
                                # Bad expiry.
                                return [ 'ipb_expiry_temp' ];
-                       } elseif ( $wgHideUserContribLimit !== false
-                               && $user->getEditCount() > $wgHideUserContribLimit
+                       } elseif ( $hideUserContribLimit !== false
+                               && $user->getEditCount() > $hideUserContribLimit
                        ) {
                                # Typically, the user should have a handful of edits.
                                # Disallow hiding users with many edits for performance.
                                return [ [ 'ipb_hide_invalid',
-                                       Message::numParam( $wgHideUserContribLimit ) ] ];
+                                       Message::numParam( $hideUserContribLimit ) ] ];
                        } elseif ( !$data['Confirm'] ) {
                                return [ 'ipb-confirmhideuser', 'ipb-confirmaction' ];
                        }
                }
  
+               $blockAllowsUTEdit = $context->getConfig()->get( 'BlockAllowsUTEdit' );
+               $userTalkEditAllowed = !$blockAllowsUTEdit || !$data['DisableUTEdit'];
+               if ( !$userTalkEditAllowed &&
+                       $isPartialBlock &&
+                       !in_array( NS_USER_TALK, explode( "\n", $data['NamespaceRestrictions'] ) )
+               ) {
+                       return [ 'ipb-prevent-user-talk-edit' ];
+               }
                # Create block object.
                $block = new DatabaseBlock();
                $block->setTarget( $target );
                $block->setReason( $data['Reason'][0] );
                $block->setExpiry( $expiryTime );
                $block->isCreateAccountBlocked( $data['CreateAccount'] );
-               $block->isUsertalkEditAllowed( !$wgBlockAllowsUTEdit || !$data['DisableUTEdit'] );
+               $block->isUsertalkEditAllowed( $userTalkEditAllowed );
                $block->isEmailBlocked( $data['DisableEmail'] );
                $block->isHardblock( $data['HardBlock'] );
                $block->isAutoblocking( $data['AutoBlock'] );
                if ( $performer->getBlock() ) {
                        if ( $target instanceof User && $target->getId() == $performer->getId() ) {
                                # User is trying to unblock themselves
 -                              // @TODO Ensure that the block does not apply to the `unblockself`
 -                              //       right.
                                if ( $performer->isAllowed( 'unblockself' ) ) {
                                        return true;
                                        # User blocked themselves and is now trying to reverse it
diff --combined languages/i18n/en.json
        "rcfilters-clear-all-filters": "Clear all filters",
        "rcfilters-show-new-changes": "View new changes since $1",
        "rcfilters-search-placeholder": "Filter changes (use menu or search for filter name)",
 +      "rcfilters-search-placeholder-mobile": "Filters",
        "rcfilters-invalid-filter": "Invalid filter",
        "rcfilters-empty-filter": "No active filters. All contributions are shown.",
        "rcfilters-filterlist-title": "Filters",
        "block-log-flags-angry-autoblock": "enhanced autoblock enabled",
        "block-log-flags-hiddenname": "username hidden",
        "range_block_disabled": "The administrator ability to create range blocks is disabled.",
+       "ipb-prevent-user-talk-edit": "Editing their own talk page must be allowed for a partial block, unless it includes a restriction on the User Talk namespace.",
        "ipb_expiry_invalid": "Expiry time invalid.",
        "ipb_expiry_old": "Expiry time is in the past.",
        "ipb_expiry_temp": "Hidden username blocks must be permanent.",
        "linkaccounts": "Link accounts",
        "linkaccounts-success-text": "The account was linked.",
        "linkaccounts-submit": "Link accounts",
 +      "cannotunlink-no-provider-title": "There are no linked accounts to unlink",
 +      "cannotunlink-no-provider": "There are no linked accounts that can be unlinked.",
        "unlinkaccounts": "Unlink accounts",
        "unlinkaccounts-success": "The account was unlinked.",
        "authenticationdatachange-ignored": "The authentication data change was not handled. Maybe no provider was configured?",
diff --combined languages/i18n/qqq.json
        "rcfilters-clear-all-filters": "Title for the button that clears all filters",
        "rcfilters-show-new-changes": "Label for the button to show new changes. Parameters:\n* $1 - timestamp from which new changes are available. It indicates that clicking the refresh link will bring changes newer than (or equal to) this timestamp. It is formatted according to the user's date, time and timezone preferences",
        "rcfilters-search-placeholder": "Placeholder for the filter search input. The first \"Filter\" is a verb, and the second \"filter\" is a noun.",
 +      "rcfilters-search-placeholder-mobile": "Placeholder for the filter search input for mobile devices.",
        "rcfilters-invalid-filter": "A label for an invalid filter.",
        "rcfilters-empty-filter": "Placeholder for the filter list when no filters were chosen.",
        "rcfilters-filterlist-title": "Title for the filters list.\n{{Identical|Filter}}",
        "block-log-flags-angry-autoblock": "Used as a block log flag in [[Special:Log/block]].\n{{Related|Block-log-flags}}",
        "block-log-flags-hiddenname": "Used as a block log flag in [[Special:Log/block]] and in [[Special:Block]].\n\n{{Related|Block-log-flags}}",
        "range_block_disabled": "Used as error message in [[Special:Block]].\n\nSee also:\n* {{msg-mw|Range block disabled}}\n* {{msg-mw|Ip range invalid}}\n* {{msg-mw|Ip range toolarge}}",
+       "ipb-prevent-user-talk-edit": "Used as error message in [[Special:Block]] if invalid options are selected regarding \"Edit own user talk\".\n\nSee also:\n{{msg-mw|ipb-disableusertalk}}",
        "ipb_expiry_invalid": "Used as error message in [[Special:Block]].",
        "ipb_expiry_old": "Used as error message in [[Special:Block]], if the expiry time is in the past.\n{{Identical|protect_expiry_old}}",
        "ipb_expiry_temp": "Warning message displayed on [[Special:Block]] if the option \"hide username\" is selected but the expiry time is not infinite.",
        "linkaccounts": "Title of the special page [[Special:LinkAccounts]] which allows the user to connect the local user accounts with external ones such as Google or Facebook.",
        "linkaccounts-success-text": "Text shown on top of the form after a successful action.",
        "linkaccounts-submit": "Text of the main submit button on [[Special:LinkAccounts]] (when there is one)",
 +      "cannotunlink-no-provider-title": "Error page title shown when the user visits [[Special:UnlinkAccounts]] but there is no external account that could be unlinked.",
 +      "cannotunlink-no-provider": "Error message shown when the user visits [[Special:UnlinkAccounts]] but there is no external account that could be unlinked.",
        "unlinkaccounts": "Title of the special page [[Special:UnlinkAccounts]] which allows the user to remove linked remote accounts.",
        "unlinkaccounts-success": "Account unlinking form success message",
        "authenticationdatachange-ignored": "Shown when authentication data change was unsuccessful due to configuration problems.\n\nCf. e.g. {{msg-mw|Passwordreset-ignored}}.",