Feature summary
$wgDisableHardRedirects prevents two types of redirects from being “hard redirects,” and turns them into “soft redirects,” which require another click:
- Interwiki redirects to other wikis
- Redirects to special pages
Reference: https://www.mediawiki.org/wiki/Manual:$wgDisableHardRedirects
These are two different things, which is in violation of the Single Responsibility Principle (https://en.wikipedia.org/wiki/Single-responsibility_principle). It's also not terribly transparent as to what a “hard redirect” actually is. Both contribute to Technical-Debt
Shortcut redirects to special pages do make some sense (👍). It's convenient to type in a shortcut into the search box and press enter. But third-party wikis really do not want users to be whisked off to a completely different website, that's not controlled by the 3rd party, without warning having clicked on a normal-looking blue link (🤦).
Also, since T384578: Check Title::isValidRedirectTarget on redirect creation was implemented, redirects to universally-blocked special pages like [[Special:LogOut]] get an error message thrown. But on WMF wikis with $wgDisableHardRedirects=true, redirects to other special pages have exactly the same behaviour but not the warning message. Allow links to special pages and this inconsistency goes away.
T326054: Special pages don't display Mediawiki:redirectfrom (aka mw-redirectfrom) when redirected to would be relatively straightforward to fix. It probably needs to be fixed first though, before this one.
Proposal
This configuration should be split into two different configurations, or at least one of them split off into something like:
- $wgDisableHardRedirectsToSpecialPages
- $wgDisableHardInterWikiRedirects
Needs discussion. It may be worth just allowing the links to special pages universally? What's the honest objection against them?
- Notes **
DisableHardRedirects occurs 7 times in code (Code search)
- Core: docs/config-vars.php
- docs/config-schema.yaml
- includes/MainConfigSchema.php
- includes/actions/ActionEntryPoint.php
- includes/config-schema.php
plus:
- labs/countervandalism/cvn-infrastructure
- operations/mediawiki-config
The last two have something to do with specifically excluding https://www.donatewiki.org so the WMF can hoover in those juicy, juicy donations. They're external interwiki links.
1. docs/config-schema.yaml
This defines the variable as follows:
DisableHardRedirects: default: false description: |- Disable redirects to special pages and interwiki redirects, which use a 302 and have no "redirected from" link. @note This is only for articles with #REDIRECT in them. URL's containing a local interwiki prefix (or a non-canonical special page name) are still hard redirected regardless of this setting.
2. docs/config-vars.php
/** * Config variable stub for the DisableHardRedirects setting, for use by phpdoc and IDEs. * @see MediaWiki\MainConfigSchema::DisableHardRedirects */ $wgDisableHardRedirects = null; /**
- includes/MainConfigNames.php
lines:
/** * Name constant for the DisableHardRedirects setting, for use with Config::get() * @see MainConfigSchema::DisableHardRedirects */ public const DisableHardRedirects = 'DisableHardRedirects';
- includes/MainConfigSchema.php
/** * Disable redirects to special pages and interwiki redirects, which use a 302 * and have no "redirected from" link. * * @note This is only for articles with #REDIRECT in them. URL's containing a * local interwiki prefix (or a non-canonical special page name) are still hard * redirected regardless of this setting. */ public const DisableHardRedirects = [ 'default' => false, ];
- includes/actions/ActionEntryPoint.php
// Follow redirects only for... redirects. // If $target is set, then a hook wanted to redirect. if ( !$ignoreRedirect && ( $target || $page->isRedirect() ) ) { // Is the target already set by an extension? $target = $target ?: $page->followRedirect(); if ( is_string( $target ) && !$this->getConfig( MainConfigNames::DisableHardRedirects ) ) { // we'll need to redirect return $target; }
- includes/config-schema.php
Just says:
'DisableHardRedirects' => false,
(6) appears to be the critical one here., in particular, is &$ignoreRedirect which is a boolean value that occurs several times in code: code search.