Page MenuHomePhabricator

[BUG] InvalidArgumentException "Blocker must be a local user or a name that cannot be a local user"
Closed, ResolvedPublicBUG REPORT

Description

What is the problem?

When a user's language is different from the wiki's default language and they have a proxy or DNS block against them, they may see (see reprod. steps below):

Fatal exception of type "InvalidArgumentException"

(full exception below)

I think what is happening is:

  • when we instantiate the system block we set the "blocker" to be a localised string based on the user's language (here and here)
  • when checking if the blocker's name is valid, we compare to a list of $wgReservedUsernames which are localised based on the wiki's language (here)
  • where the wiki's and user's translations of the strings differ, the strings don't match and we see the exception

Full stack trace:

[exception] [b158ac783c872a375d731a51] /core/index.php?title=Main_Page&action=edit   InvalidArgumentException from line 491 of /var/www/html/core/includes/block/AbstractBlock.php: Blocker must be a local user or a name that cannot be a local user
#0 /var/www/html/core/includes/block/AbstractBlock.php(105): MediaWiki\Block\AbstractBlock->setBlocker(User)
#1 /var/www/html/core/includes/block/SystemBlock.php(49): MediaWiki\Block\AbstractBlock->__construct(array)
#2 /var/www/html/core/includes/block/BlockManager.php(136): MediaWiki\Block\SystemBlock->__construct(array)
#3 /var/www/html/core/includes/user/User.php(1763): MediaWiki\Block\BlockManager->getUserBlock(User, boolean)
#4 /var/www/html/core/includes/user/User.php(2090): User->getBlockedStatus(boolean)
#5 /var/www/html/core/includes/Permissions/PermissionManager.php(635): User->getBlock(boolean)
#6 /var/www/html/core/includes/Permissions/PermissionManager.php(375): MediaWiki\Permissions\PermissionManager->checkUserBlock(string, User, array, string, boolean, Title)
#7 /var/www/html/core/includes/Permissions/PermissionManager.php(258): MediaWiki\Permissions\PermissionManager->getPermissionErrorsInternal(string, User, Title, string)
#8 /var/www/html/core/includes/Title.php(2294): MediaWiki\Permissions\PermissionManager->getPermissionErrors(string, User, Title, string, array)
#9 /var/www/html/core/includes/EditPage.php(715): Title->getUserPermissionsErrors(string, User, string)
#10 /var/www/html/core/includes/EditPage.php(619): EditPage->getEditPermissionErrors(string)
#11 /var/www/html/core/includes/actions/EditAction.php(55): EditPage->edit()
#12 /var/www/html/core/includes/MediaWiki.php(499): EditAction->show()
#13 /var/www/html/core/includes/MediaWiki.php(294): MediaWiki->performAction(Article, Title)
#14 /var/www/html/core/includes/MediaWiki.php(884): MediaWiki->performRequest()
#15 /var/www/html/core/includes/MediaWiki.php(515): MediaWiki->main()
#16 /var/www/html/core/index.php(42): MediaWiki->run()
#17 {main}

This has the same exception as T192964, but I think they might have different causes. T192964 involves database blocks, whereas I have only been able to reproduce my bug with system blocks.

Steps to reproduce problem

Here are several examples:

Example one
  1. In LocalSettings.php: $wgLanguageCode = "en"; $wgProxyList = [ '$ip' ];
  2. From $ip, navigate to /wiki/index.php?title=Main_Page&action=edit&uselang=hsb
Example two
  1. In LocalSettings.php: $wgLanguageCode = "en"; $wgProxyList = [ '$ip' ];
  2. Login from $ip as a user whose language is "fr"
Example three
  1. In LocalSettings.php: $wgLanguageCode = "en"; $wgEnableDnsBlacklist = true; $wgDnsBlacklistUrls = [ 'xip.io.' ];
  2. From $ip, navigate to /wiki/index.php?title=Main_Page&action=edit&uselang=hsb

Expected behavior: Page will load; You will see a block message.
Observed behavior: Fatal exception of type "InvalidArgumentException"

It should be noted that not all languages are effected on all wikis. For example, many languages use the same translation of 'sorbs', or have no translation of 'proxyblocker' and fallback to en (on an en wiki, presumably).

Environment

Operating system: Debian Stretch
Wiki(s): 1.32.1 and 1.34.0-alpha (c92d559)

Details

Related Gerrit Patches:

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 12 2019, 2:59 PM
Tchanders added a subscriber: Tchanders.

Thanks for the examples - we could try to address this while working on block error messages.

I think what is happening is:

  • when we instantiate the system block we set the "blocker" to be a localised string based on the user's language [...]
  • when checking if the blocker's name is valid, we compare to a list of $wgReservedUsernames which are localised based on the wiki's language [...]
  • where the wiki's and user's translations of the strings differ, the strings don't match and we see the exception

Agreed. Here are two related tasks:

  • The blocker for a SystemBlock does not need to be a User - T227005 (that would fix this problem, but not T192964 of course)
  • The blocker's name should not be stored as a translated message - T227007
Restricted Application added a subscriber: MGChecker. · View Herald TranscriptJul 12 2019, 5:30 PM
dom_walden updated the task description. (Show Details)Jul 14 2019, 11:12 AM
Niharika triaged this task as Medium priority.Jul 31 2019, 3:54 PM
Niharika set the point value for this task to 3.
Niharika removed the point value for this task.
Niharika added a subscriber: Niharika.

This is waiting until child task T227005: Don't require that the blocker be a User for a SystemBlock is resolved.

aezell closed this task as Resolved.Aug 22 2019, 6:43 PM
aezell claimed this task.
aezell moved this task from Cards ready to be discussed to Backlog on the Anti-Harassment board.
aezell reopened this task as Open.Sep 19 2019, 1:26 PM
aezell removed aezell as the assignee of this task.
aezell added a subscriber: aezell.

Change 540940 had a related patch set uploaded (by Dmaza; owner: Dmaza):
[mediawiki/core@master] Remove blocker dependency for System and Composite blocks

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

Change 540940 merged by jenkins-bot:
[mediawiki/core@master] Remove blocker dependency for System and Composite blocks

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

Tchanders assigned this task to dmaza.Nov 1 2019, 3:09 PM

I can no longer reproduce this following reproduction steps, on my local VM MediaWiki 1.35.0-alpha (68d87db) 04:22, 1 November 2019.

Tchanders closed this task as Resolved.Nov 6 2019, 2:52 PM