https://bugzilla.wikimedia.org/show_bug.cgi?id=54745
Web browser: --- Bug ID: 54745 Summary: Page.iterlanglinks for a page on commons returns pages on commons Product: Pywikibot Version: unspecified Hardware: All OS: All Status: NEW Severity: normal Priority: Unprioritized Component: General Assignee: Pywikipedia-bugs@lists.wikimedia.org Reporter: legoktm.wikipedia@gmail.com Classification: Unclassified Mobile Platform: ---
import pywikibot as p s=p.Site('commons','commons') pg=p.Page(s, 'New York City') for i in pg.iterlanglinks(): print i.site
... commons:commons <snip>
There are a few things that are working together to cause this:
iterlanglinks calls Site.pagelanglinks which does:
yield pywikibot.Link.langlinkUnsafe(linkdata['lang'], linkdata['*'], source=self)
In langlinkUnsafe, there is: link._site = pywikibot.Site(lang, source.family.name)
Now, unfortunately for commons:
p.Site('en','commons')
Site("commons", "commons")
Another issue is that https://commons.wikimedia.org/w/api.php?action=query&titles=New%20York%2... (the actual API query we make) only returns language codes, not full database names.
https://bugzilla.wikimedia.org/show_bug.cgi?id=54745
Sorawee Porncharoenwase nullzero.free@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |nullzero.free@gmail.com
--- Comment #1 from Sorawee Porncharoenwase nullzero.free@gmail.com --- Then, what site it should return? [[enwikivoyage:New York City]] or [[New York City]]?
In my opinion, there should be an additional parameter which indicates the family we are looking at. The default value would be none, indicating that it should look for its own family. Therefore, in this case, calling langlinks() should get empty list. Calling langlinks(fam='wikipedia') would get the list of pages whose site is Wikipedia. blah blah
https://bugzilla.wikimedia.org/show_bug.cgi?id=54745
Maarten Dammers maarten@mdammers.nl changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |maarten@mdammers.nl
--- Comment #2 from Maarten Dammers maarten@mdammers.nl --- Commons is a weird wiki. The langlinks point to Wikipedia. That should be the behavior in the bot too.
https://bugzilla.wikimedia.org/show_bug.cgi?id=54745
--- Comment #3 from Gerrit Notification Bot gerritadmin@wikimedia.org --- Change 138299 had a related patch set uploaded by John Vandenberg: Bug 54745: Link.langlinkUnsafe interwiki_forward
https://gerrit.wikimedia.org/r/138299
https://bugzilla.wikimedia.org/show_bug.cgi?id=54745
Gerrit Notification Bot gerritadmin@wikimedia.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |PATCH_TO_REVIEW
https://bugzilla.wikimedia.org/show_bug.cgi?id=54745
--- Comment #4 from Gerrit Notification Bot gerritadmin@wikimedia.org --- Change 138299 merged by jenkins-bot: Bug 54745: Link.langlinkUnsafe interwiki_forward
https://gerrit.wikimedia.org/r/138299
https://bugzilla.wikimedia.org/show_bug.cgi?id=54745
Ricordisamoa ricordisamoa@openmailbox.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|PATCH_TO_REVIEW |NEW
--- Comment #5 from Ricordisamoa ricordisamoa@openmailbox.org --- Should we change this in compat, too?
https://bugzilla.wikimedia.org/show_bug.cgi?id=54745
John Mark Vandenberg jayvdb@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Version|unspecified |core (2.0) Resolution|--- |FIXED Whiteboard| |backportable
pywikipedia-bugs@lists.wikimedia.org