Show namespace instead of SpecialAllPages in plaintext block log message

Ensure that when constructing a plaintext block log message
for a partial block that the namespace is shown. Currently
because makePageLink in plaintext mode uses the page title
and does not include the $html text, which is used in non-
plaintext mode, it means that for namespace blocks the shown
text is "Special:AllPages".

There is no way to link to Special:AllPages with a specified
namespace while in plaintext mode because the namespace query
parameter cannot be included in the wikilink. This means that,
if the page was still linked to, the link would just show all pages.
As such, unless other patches are submitted to allow the namespace
to be specified when linking through a wikilink, the link is
best removed.

The plaintext value of the namespace is used by the CheckUser
extension, which is what the relevant bug reports issues with.

Bug: T268156
Change-Id: Ic05ae1adf92cb806517226d74bf2edc9a89251cd
This commit is contained in:
dreamyjazz 2022-05-31 18:41:16 +01:00
parent 13326760a7
commit 777cd78136

View file

@ -90,9 +90,18 @@ class BlockLogFormatter extends LogFormatter {
$text = (int)$ns === NS_MAIN
? $this->msg( 'blanknamespace' )->escaped()
: htmlspecialchars( $this->context->getLanguage()->getFormattedNsText( $ns ) );
$params = [ 'namespace' => $ns ];
return $this->makePageLink( SpecialPage::getTitleFor( 'Allpages' ), $params, $text );
if ( $this->plaintext ) {
// Because the plaintext cannot link to the Special:AllPages
// link that is linked to in non-plaintext mode, just return
// the name of the namespace.
return $text;
} else {
return $this->makePageLink(
SpecialPage::getTitleFor( 'Allpages' ),
[ 'namespace' => $ns ],
$text
);
}
}, $namespaces );
$actions = $params[6]['actions'] ?? [];