Page MenuHomePhabricator

[SPIKE] - Investigate steps required to add a Block link to the overflow menu for administrators [8hr]
Closed, ResolvedPublicSpike

Description

As an administrator, I want to block a user from editing my Wikimedia project from my mobile device, so that I can stop them vandalising pages.

There are a number of administrator tools which are accessible from dropdown menus in the top right of a page in desktop view, or in the left sidebar. Functionality like Delete, Protect, and changing user groups have been made available via Advanced Mobile Contributions' overflow menu on mobile web. When on a user page, users expect to find a link to Block this user in the same menu, but this isn't currently present.

The link would probably need to take users to Special:Block/USERNAME.

Questions

  • What steps would be required to add a Block link to the overflow menu? It should be visible only to users who can block others (probably using the same logic as Delete and Protect), and only visible on User and User talk namespace pages.

Event Timeline

Restricted Application changed the subtype of this task from "Task" to "Spike". · View Herald TranscriptApr 14 2022, 11:15 AM
Restricted Application added subscribers: Masumrezarock100, Aklapper. · View Herald Transcript
Samwalton9 triaged this task as Medium priority.Apr 14 2022, 2:50 PM
Samwalton9 renamed this task from [SPIKE] Investigate steps required to add a Block link to the overflow menu for administrators [8hr] to [SPIKE] - Investigate steps required to add a Block link to the overflow menu for administrators [8hr].Apr 26 2022, 9:34 AM
Samwalton9 updated the task description. (Show Details)

What steps would be required to add a Block link to the overflow menu?

One file we would need to modify is skins/MinervaNeue/includes/Menu/PageActions/UserNamespaceOverflowBuilder.php, specifically the $possibleEntries array (reference). Adding this new item to the array will only make it visible on User and User talk namespace pages.

In that file, there is a method called buildFromToolbox, where a $toolbox variable is passed. This array comes from the main Skin.php file in MediaWiki core in a function aptly named makeToolbox. This function in turn calls buildNavUrls, where there is a blockip option that we need. I tried adding this option in my local test environment, but it doesn't appear in my overflow menu. Maybe my user lacks permissions? See here. I feel adding a new element with the blockip option is a probable solution for adding a block option in the overflow menu.

It should be visible only to users who can block others (probably using the same logic as Delete and Protect)

This is checked here. The users I created in my local environment don't seem to have block permission. I wonder what we need to change to be able to test it locally.

Thanks Susana!

I notice the buildNavUrls option is called blockip - is that used both for blocking users and for blocking unregistered users (IPs?) Both are handled on the same page, I just wanted to check since the option has 'IP' in the name.

The users I created in my local environment don't seem to have block permission. I wonder what we need to change to be able to test it locally.

Ah I should have clarified this :) Usually only administrators can block users. On Wikipedia blocking means preventing the user from editing the project entirely (or partially), rather than something like a social media 'block' which prevents specific user-to-user interaction.

Looking at https://www.mediawiki.org/wiki/Manual:User_rights, it looks like just the block user right is relevant, which is provided to sysops by default. From a quick look at https://noc.wikimedia.org/conf/InitialiseSettings.php.txt it looks like there are wikis where users in groups other than sysop can use block, so is it possible for us to check for user right rather than user group here?

Just looking through this today, and I think there's enough here for me to pick up implementation next week.

Having looked things over I *think* I can answer @Samwalton9's questions:

I notice the buildNavUrls option is called blockip - is that used both for blocking users and for blocking unregistered users (IPs?) Both are handled on the same page, I just wanted to check since the option has 'IP' in the name.

Yes, blockip is a core hook called just before user/ip blocking, and that's the nomenclature used throughout code for blocking. Anonymous users go through many of the same code paths as authenticated users and are referenced by ip.

is it possible for us to check for user right rather than user group here?

It lookes possible to me. Looking at the way the code is written, we'd probably need to add a new method for doing a direct rights check, since this one is specifically geared towards groups.

Thanks for the additional info @Samwalton9 and for answering the questions @jsn.sherman!

Thanks both! Filed T307341.

I also filed T307344 for adding data tracking to this item