Page MenuHomePhabricator

Partial blocks from namespaces are displayed odd
Closed, ResolvedPublic3 Estimated Story PointsBUG REPORT

Description

In both the Special:CheckUser and Special:Investigate/Timeline displays, partial blocks from namespaces are all shown as the namespace Special:AllPages (with Special:AllPages being linked to the special page) rather than saying which namespace is actually being blocked.

I suspect this is because, in the entries in Special:Log, the namespace name is linked to Special:AllPages for that namespace? See BlockLogFormatter::getMessageParameters

Steps to reproduce

  • Block a user from a namespace (e.g. Talk)
  • Navigate to Special:Investigate and start an investigation for the admin who made the block
  • Go to the Timeline tab
  • Expected: A log line says that the admin blocked another user "from the namespace Talk"
  • Actual: A log line says that the admin blocked another user "from the namespace Special:AllPages"

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.
StatusSubtypeAssignedTask
ResolvedBUG REPORTDreamy_Jazz
ResolvedDreamy_Jazz

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
DannyS712 changed the subtype of this task from "Task" to "Bug Report".
DannyS712 moved this task from Unsorted to Reports on the User-DannyS712 board.

@Tchanders might have more to add about why this happens.

Example on my local docker on Special:CheckUser:

special_checkuser_namespaces.png (405×1 px, 78 KB)

And on Special:Investigate:

special_investigate_namespaces.png (442×1 px, 55 KB)

This is the block whose log item they are referring to above:

special_blocklist_namespaces.png (207×1 px, 27 KB)

STran set the point value for this task to 3.Feb 14 2022, 6:17 PM

Can verify that this still happens. Will look at maybe writing something.

This seems to be because the checkuser extension gets the plaintext version of the log entry, unlike recent changes and the block log entry etc. The plaintext version seems to not return correctly when being parsed.

I've found the cause:

makePageLink() is called by getMessageParameters(). However, if $this->plaintext is set to true (this is the case on getPlainActionText() which is called by the CU extension) then it will return a wikilink which is constructed as follows:

$link = '[[' . $title->getPrefixedText() . ']]';

This means that if the plaintext version (i.e. not HTML) is desired by the caller, the page name is returned wrapped in double square brackets. This explains why they are all Special:AllPages as this is the name of the page linked to in the log. The Checkuser extension stores the plaintext value of the action text in the DB and so when served up in the CU log it uses the plaintext version (which can include wikitext).

To add link text (i.e. Talk / User showing instead of Special:AllPages) I have been able to modify the line to include the $html parameter after it was stripped (using PHP's strip_tags). I have also tried out using a separate parameter, as stripping the HTML tags from something that uses complicated HTML in the $html parameter may end up with a confusing link text value. This would lead the CU log to have [[Special:Allpages|Talk]] which while better, does not filter the pages in the linked to page to just that namespace. Some code snippets:

$link = '[[' . $title->getPrefixedText();
if ( $html !== null ) {
	$link .= "|" . strip_tags($html);
}
$link .= "]]";
$link = '[[' . $title->getPrefixedText();
if ( $plaintext !== null ) {
	$link .= "|" . $plaintext;
}
$link .= "]]";

To add the namespace, it would require special page to allow the namespace to be specified in the name of the page and not any query parameters. This is because wikilinks do not support query parameters. This special page does not support that, however, the ways around this that might be possible are using magic functions (i.e. {{canonicalurl:page name}}) or specifying a external link using wikitext (i.e. single opening and closing square bracket). I don't know if this would work, and I have not tested this.

If an external link is not desired and plaintext has to be used, then removing the link to Special:Allpages may be better as it would still show the namespace name but just not be clickable.

The last idea I had is if the actor column could, instead, store HTML. Any previous actor entries would have to be modified to have any HTML characters escaped but this would allow the column to store the HTML output which is used in log pages etc. However, storing as HTML would exceed the current maximum log length very easily and the current method of cutting off would lead to unclosed HTML. This means that the column in the DB would need to be changed.

This is probably too much for me to do right now, so leaving for anyone else.

Alternatively if T145265 is implemented, then the problem would be circumvented as the raw data instead of the plaintext / HTML output would be stored for use when searching CU logs.

From what I can tell the schema changes to make action text be stored in a more structured format is going to take a while to be dealt with. Therefore in the meantime a patch that simply removes the link to Special:AllPages while leaving the namespace blocked from as plaintext could be used to help address this. CUs will be aware of the meaning of each namespace, so having this link isn't probably needed. However, once the data can be stored in a more structured way this stop gap could be reverted.

Change 801783 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/core@master] Show namespace instead of Special:AllPages in plaintext block log message

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

I've submitted a patch that shows just the namespace with no link if plaintext mode is enabled. Even if a wikilink was made that linked to Special:AllPages the namespace could not be specified as wikilinks cannot include query parameters. Having no link when in plaintext mode seems best. The patch above addresses this.

If I also understand correctly any IRC feed that used this would have also had the same issue as the documentation for $plaintext says that IRC feeds turn plaintext mode on.

Change 801783 merged by jenkins-bot:

[mediawiki/core@master] Show namespace instead of SpecialAllPages in plaintext block log message

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

Umherirrender assigned this task to Dreamy_Jazz.
Umherirrender subscribed.

Just as note to avoid confusing: The fix only applied to new log entries after the deployment, because the changed code is used on store into check user, not on read of the stored data