Page MenuHomePhabricator

GlobalBlocking should specify block error message key
Closed, ResolvedPublic3 Estimated Story Points

Description

Background

Blocks can be reported to the user via several different block error messages. BlockErrorFormatter::getBlockErrorMessageKey chooses which message to use, depending on the type of block.

After T317201: Allow extensions to modify block error message key via a hook, extensions can tell BlockErrorFormatter which error message key to use. GlobalBlocking should have a handler for this hook that uses one of the extension's block messages.

Acceptance criteria
  • If there is a GlobalBlock and no other block, the error message displayed is one of 'globalblocking-ipblocked', 'globalblocking-ipblocked-range' or 'globalblocking-ipblocked-xff'
  • If there is a CompositeBlock that includes a GlobalBock, the block reason is updated to include details of the global block (see end of T317308#8276750)
  • The hooks onGlobalBlockingBlockedIpMsg, onGlobalBlockingBlockedIpRangeMsg and onGlobalBlockingBlockedIpXffMsg are run so that WikimediaMessages can alter the message keys
  • If there is no global block, nothing is changed
Notes

See GlobalBlocking::getUserBlockDetails for how the message keys are currently chosen

Testing notes

This task affects anywhere that throws a UserBlockedError with a global block. One example in core is SpecialUpload.

Before testing:

  • This should be tested with and without the WikimediaMessages extension. (This might mean it needs to be tested locally?)
  • This needs to be tested with T317201. (That patch has been merged, but if testing locally core may need updating.)
  • Where testing with WikimediaMessages, this should be tested with T321574: Override new GlobalBlocking messages on WikimediaMessages

Steps to test (without WikimediaMessages):

  • Globally block your IP address. (Make sure there are no local blocks or other local blocks against your IP address.)
  • Log out and visit Special:Upload
  • Before this change, the message to tell you you are blocked is blockedtext
  • After this change, the blocked message should be globalblocking-blockedtext-ip

Repeat this, but in the first 2 steps:

  • block an IP range covering your IP address. The new message should be globalblocking-blockedtext-range.
  • change your XFF header using a browser extension such as [[ chrome://extensions/?id=hkghghbnihliadkabmlcmcgmffllglin | this one ]], and block that IP address. The new message should be globalblocking-blockedtext-xff.

Repeat all of the above with WikimediaMessages enabled. The messages should be as above, prefixed with wikimedia-.

Related Objects

StatusSubtypeAssignedTask
OpenNone
OpenNone
OpenSpikeNone
ResolvedCyndymediawiksim
ResolvedCyndymediawiksim
Resolved AGueyte
Resolved TThoabala
Resolved AGueyte
ResolvedWMDE-Fisch
Resolved AGueyte
ResolvedCyndymediawiksim
ResolvedCyndymediawiksim
OpenNone
OpenNone
OpenNone
ResolvedTchanders
ResolvedTchanders
Resolved AGueyte

Event Timeline

Change 837185 had a related patch set uploaded (by Tchanders; author: Tchanders):

[mediawiki/extensions/GlobalBlocking@master] WIP: Override block error message for global blocks

https://gerrit.wikimedia.org/r/837185

Change 837185 had a related patch set uploaded (by Tchanders; author: Tchanders):

[mediawiki/extensions/GlobalBlocking@master] WIP: Override block error message for global blocks

https://gerrit.wikimedia.org/r/837185

I made this patch to help test T317201: Allow extensions to modify block error message key via a hook.

I noticed some problems while making it:

  • The messages 'globalblocking-ipblocked', 'globalblocking-ipblocked-range' or 'globalblocking-ipblocked-xff' take params in a different order from BlockErrorFormatter::getBlockErrorMessageParams. This means we can't just swap these keys in.
  • We could make new messages (which is what the patch does). But they would have to be kept exactly the same as the older messages, which is a maintenance burden. (These messages are carefully worded (see e.g. T310131: Update/reword wikimedia-globalblocking-.* message overrides). @MarcoAurelio Might it be feasible to migrate these messages, e.g. replace globalblocking-ipblocked with the new message in: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/GlobalBlocking/+/837185/1/i18n/en.json#77
  • There is one parameter in 'globalblocking-ipblocked' and friends that BlockErrorFormatter does not have access to, which is the wiki of the blocker. However, that will be captured in the blocker's name (e.g. "SomeAdmin>enwiki"), so I don't think it's a problem.
  • If there is a CompositeBlock that includes a GlobalBock, the block reason is updated to include details of the global block

I'm no longer sure about this. It's not very nice architecturally. If there are several blocks, is it right to add specific details for global blocks in particular? If so, we should probably solve the bigger problem of how to report details of CompositeBlocks rather than hacking the block reason for global blocks here.

  • The messages 'globalblocking-ipblocked', 'globalblocking-ipblocked-range' or 'globalblocking-ipblocked-xff' take params in a different order from BlockErrorFormatter::getBlockErrorMessageParams. This means we can't just swap these keys in.

We could just swap the order of the parameters. The danger is that on-wiki overrides (e.g. this one) would no longer work, because they would have the old parameter order.

However, it looks like there aren't many overrides:

...so we could fix them manually.

  • The messages 'globalblocking-ipblocked', 'globalblocking-ipblocked-range' or 'globalblocking-ipblocked-xff' take params in a different order from BlockErrorFormatter::getBlockErrorMessageParams. This means we can't just swap these keys in.

We could just swap the order of the parameters. The danger is that on-wiki overrides (e.g. this one) would no longer work, because they would have the old parameter order.

However, it looks like there aren't many overrides:

...so we could fix them manually.

Swapping parameter order looks like it will be a nightmare, since we'd need simultaneous deployments of our code, WikimediaMessages, on-wiki overrides and updated translations.

However, introducing new messages would be complicated too. We'd need to:

  • Introduce new messages in GlobalBlocking, with the same English translations as the old messages, but a new parameter order
  • Get these translated
  • Do the same for the WikimediaMessages overrides
  • Get these translated too
  • Add on-wiki overrides for the new messages, equivalent to the old messages' overrides in T317308#8308355

@Amire80 Do you have any ideas about what we could do here?

Can you give a clearer example of what do you want to change in the message? The current English source text is:

'''Your IP address has been blocked on all wikis.'''

The block was made by $1 ($2).
The reason given is ''$3''.

* Start of block: $4
* Expiration of block: $5

You can contact $1 to discuss the block.
You cannot use the "{{int:emailuser}}" feature unless a valid email address is specified in your [[Special:Preferences|account preferences]] and you have not been blocked from using it.
Your current IP address is $6.
Please include all above details in any queries you make.

Which ones do you want to change?

Can you give a clearer example of what do you want to change in the message? The current English source text is:

'''Your IP address has been blocked on all wikis.'''

The block was made by $1 ($2).
The reason given is ''$3''.

* Start of block: $4
* Expiration of block: $5

You can contact $1 to discuss the block.
You cannot use the "{{int:emailuser}}" feature unless a valid email address is specified in your [[Special:Preferences|account preferences]] and you have not been blocked from using it.
Your current IP address is $6.
Please include all above details in any queries you make.

Which ones do you want to change?

Sure - this message would change to the following (text unchanged, param order changed):

'''Your IP address has been blocked on all wikis.'''

The block was made by $1.
The reason given is ''$2''.

* Start of block: $8
* Expiration of block: $6

You can contact $1 to discuss the block.
You cannot use the \"{{int:emailuser}}\" feature unless a valid email address is specified in your [[Special:Preferences|account preferences]] and you have not been blocked from using it.
Your current IP address is $3.
Please include all above details in any queries you make.

Change 837185 merged by jenkins-bot:

[mediawiki/extensions/GlobalBlocking@master] Override block error message for global blocks

https://gerrit.wikimedia.org/r/837185

Without WikimediaMessages

When globally blocked and going to Special:Upload, you see the message globalblocking-blockedtext-ip, globalblocking-blockedtext-range or globalblocking-blockedtext-xff (as appropriate).

If you are also blocked locally (IP or account), you only see a message for the local block(s) (e.g. blockedtext, blockedtext-partial, blockedtext-composite). This was the same before this change.

For other actions like editing you see the message globalblocking-ipblocked, globalblocking-ipblocked-range or globalblocking-ipblocked-xff, alongside any messages for local blocks.

I will test with WikimediaMessages after T321574 is merged.

Test environment: local docker GlobalBlocking – (66f7de6) 08:02, 4 November 2022.

I am going to move this into Done. The WikimediaMessages part of this testing can be done as part of T321574.