**User story:**
As a Wikdiata editor,
I want the ability to use redirects and the target article as independent sitelinks
in order to match Wikidata and Wikipedia appropriately in complicated cases.
**Problem:**
* In T235420 we added badges to indicate sitelinks to redirects but they can't be used because the edits related to them can not be made (as redirects are followed and sitelink conflict occur)
* https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/602422 contains some work in this direction but is probably not the right approach, (per Adam's comment at T235420#6791998) Adam notes: "Looking at the patch lots of the code will end up being reused, but it will need the addition of some checks etc to optionally pass MediaWikiPageNameNormalizer::NOFOLLOW_REDIRECT into the service etc."
**Solution**
We want to allow sitelinks to redirects but only under certain conditions. In detail this means:
* The default behavior always tries to normalize sitelinks (following redirects) and thus these sitelinks are rejected in cases where the target of the redirect is already a sitelink
* A sitelink to a redirected pages can be added to an Item if and only if a redirect badge [[ https://www.wikidata.org/wiki/Special:AvailableBadges | (sitelink to redirect (Q70893996), intentional sitelink to redirect (Q70894304)) ]] is added in the same edit
* Adding a redirect badge to an existing redirect sitelink is possible
* Removing a redirect badge from a sitelink that points to a redirected page is disallowed
**BDD**
Redirects are NOT allowed as separate sitelinks if NO redirect badge is added in the same edit:
GIVEN an Item
AND a page on the client that is a redirect
AND the redirect target is already used in another Item
WHEN adding the page as a sitelink to the Item
AND not adding a redirect badge in the same edit
THEN the edit is rejected
AND the user is pointed to helpful information on how to resolve the problem
Redirects are allowed as separate sitelinks if a redirect badge is added in the same edit::
GIVEN an Item
AND a page on the client that is a redirect
WHEN adding the page as a sitelink to the Item
AND adding a redirect badge in the same edit
THEN the sitelink and associated badge are stored (even if the redirect target is already used in another Item)
Redirect badges can be added to existing sitelinks even if they are redirects:
GIVEN an Item
AND a page on the client that is a redirect
WHEN adding a redirect badge to the sitelink
THEN the badge is stored with the sitelink
Redirect badges can NOT be removed from sitelinks if the redirected target is used as a sitelink for a different Item:
GIVEN an Item
AND a page on the client that is a redirect
AND the redirect target also has a sitelink in another Wikidata Item
WHEN trying to remove the redirect badge from the sitelink
AND not adding another redirect badge in the same edit
THEN the edit is rejected
AND the user is pointed to helpful information on how to resolve the problem
A redirect badge can always be switched with another redirect badge in the same edit:
GIVEN an Item
AND a page on the client that is a redirect
AND the redirect target also has a sitelink in another Wikidata Item
WHEN trying to remove the redirect badge from the sitelink
AND adding another redirect badge in the same edit
THEN the edit is allowed
**Acceptance criteria:**
[] Default behavior remains unchanged - no need to change any error messages or similar
[] Sitelinks to redirect pages are accepted if and only if there is a redirect badge attached to them
[] Redirects are NOT allowed as separate sitelinks if NO redirect badge is added in the same edit
[] Redirects are allowed as separate sitelinks if a redirect badge is added in the same edit:
[] Redirect badges can be added to existing sitelinks even if they are redirects
[] Redirect badges can NOT be removed from sitelinks if the redirected target is used as a sitelink for a different Item
[] A redirect badge can always be switched with another redirect badge in the same edit
**Notes:**
* This requires a working multi wiki local development environment
* This requires the extensions Wikidata.org ang Wikimedia Badges, to be enabled and configured in the local dev env
* Patches from previous tickets are https://gerrit.wikimedia.org/r/c/mediawiki/core/+/602412 and https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/602422 which includes code for turning on / off specific parts of title / sitelink normalization.
**Original:**
see {T54564}