Page MenuHomePhabricator

`$wgDisableHardRedirects` should be split into 2 config settings
Open, Needs TriagePublicFeature

Description

Feature summary

$wgDisableHardRedirects prevents two types of redirects from being “hard redirects,” and turns them into “soft redirects,” which require another click:

  1. Interwiki redirects to other wikis
  2. 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)

  1. Core: docs/config-vars.php
  2. docs/config-schema.yaml
  3. includes/MainConfigSchema.php
  4. includes/actions/ActionEntryPoint.php
  5. 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

link: https://gerrit.wikimedia.org/g/mediawiki/core/+/f2cdaa7664631765b183476ae8004d36f72b94cf/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;

/**
  1. includes/MainConfigNames.php

https://gerrit.wikimedia.org/g/mediawiki/core/+/f2cdaa7664631765b183476ae8004d36f72b94cf/includes/MainConfigNames.php

lines:

	/**
	 * Name constant for the DisableHardRedirects setting, for use with Config::get()
	 * @see MainConfigSchema::DisableHardRedirects
	 */
	public const DisableHardRedirects = 'DisableHardRedirects';
  1. includes/MainConfigSchema.php

https://gerrit.wikimedia.org/g/mediawiki/core/+/f2cdaa7664631765b183476ae8004d36f72b94cf/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,
	];
  1. includes/actions/ActionEntryPoint.php

https://gerrit.wikimedia.org/g/mediawiki/core/+/f2cdaa7664631765b183476ae8004d36f72b94cf/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;
				}
  1. includes/config-schema.php

https://gerrit.wikimedia.org/g/mediawiki/core/+/f2cdaa7664631765b183476ae8004d36f72b94cf/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.

Event Timeline

Has this been raised on any wiki as a potentially desired change?

Has this been raised on any wiki as a potentially desired change?

Yes, the third party wiki I run wants to prevent interwiki redirects, but allow redirects to special pages.