There is a very unusual scenario where textlib.removeLanguageLinks will not remove obsolete interlanguage links.
removeLanguageLinks includes:
if not site.validLanguageLinks(): return text ... languages = '|'.join(site.validLanguageLinks() + list(site.family.obsolete.keys()))
As it exits early if site.validLanguageLinks() doesnt return a value, the current algorithm for site.validLanguageLinks() is:
nsnames = [name for name in self.namespaces.values()] return [lang for lang in self.languages() if first_upper(lang) not in nsnames]
The scenario which does not work is:
- A wiki family called foo has two codes: 'en', and 'de' , with the interwikimap set up so that en is the English language site and de is the German language site, linked together.
- The wiki community decides two wikis is duplicated effort, so they merge the wikis into a multilingual wiki. The de site is retired, all content is copied to the en site, and the sysadmin deletes de from the interwikimap of en.
- A bot operator creates a Family mapping obsolete with de and en, and puts in langs new site foo, because it is multilingual site.
- The bots running on foo are supposed to remove all 'de' interlanguage links from the foo (was en) site. This does not happen, because 'Foo' is the name of the Project namespace.
The workaround to this is the Family needs to use a non-namespace code (e.g. en ), until the de interlanguage links are removed, and then change the code from en to foo after all internal language links to de have been removed.
Or, we can fix the bug ;-)