Page MenuHomePhabricator

Warning message about redirect to missing page is wrongly shown when redirecting to special page or interwiki
Closed, ResolvedPublic

Description

You can create redirects that point to special pages:

#REDIRECT [[special:blankpage]]

As well as redirects that point to interwiki links: (on Wikimedia wikis, these behave like "soft" redirects, but they're still valid)

#REDIRECT [[google:test]]

When you do, you'll get the warning message that it shown when creating a redirect to a page that doesn't exist (since T326057):

Warning: You are redirecting this page to a page which does not exist. You may have specified the wrong target for the redirect. If you click "Publish page" again, the redirect will be created anyway.

image.png (838×1 px, 106 KB)

(I noticed this while testing the patch for T326056)

Event Timeline

This is working as intended IMO - the page won't actually work as a redirect, and the warning should reflect that.

They're disabled on Wikimedia wikis (using $wgDisableHardRedirects here), but they work by default in MediaWiki. Redirects to special pages have a few exceptions like Special:UserLogout, and redirects to interwiki links require the interwiki prefix to be marked as "local"/"forward".

I set up examples to show this:

I guess maybe there could be a different warning message for the cases that don't work, but there definitely shouldn't be a message that talks about "a page which does not exist".

Yes, I see the problem here. 🤦

  1. Links to special pages that actually exist should, I think, be allowed through without the error message. They're valid internal pages, and such redirects are usually allowed in MediaWiki -- I'm not sure why they're disallowed on WMF wikis. But a link to [[Special:NotASpecialPage]] should throw an error.
  2. "Soft redirects" to external websites should be a separate discussion. I think there are two bugs here, not one.

I took a look at the logic used for deciding whether a link will be rendered as a "bluelink" or a "redlink". Using Title::isKnown instead of Title::exists fixes the issues with the edit constraint and does not longer return a warning if the redirect is pointing at an existing special page or any interwiki link with a valid interwiki prefix.

Whether wgDisableHardRedirects is set to true can probably be ignored here since the redirect would still be valid and working, just treated as a soft redirect.

A warning for redirecting to pages like Special:UserLogout that are not valid redirect targets (can be checked with Title::isValidRedirectTarget) should be done in a separate edit constraint in my opinion since the warning message for broken redirects would not fit. Also, the resulting redirect would be more of an "invalid redirect" instead of a "broken redirect" since all broken redirects are listed at Special:BrokenRedirects, which is not the case for redirects to invalid targets.

Change #1113519 had a related patch set uploaded (by SomeRandomDeveloper; author: SomeRandomDeveloper):

[mediawiki/core@master] Fix broken redirect warning showing for special or interwiki targets

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

So I guess if this task is to be completed, one final check needs adding.

I've added (T384578) for completeness' sake.

Change #1113519 merged by jenkins-bot:

[mediawiki/core@master] Fix broken redirect warning showing for special or interwiki targets

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

Thanks for patching it @SomeRandomDeveloper, and thanks for filing the other task @Bugreporter2.