Last modified: 2014-09-18 10:25:07 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T56745, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 54745 - Page.iterlanglinks for a page on commons returns pages on commons
Page.iterlanglinks for a page on commons returns pages on commons
Status: RESOLVED FIXED
Product: Pywikibot
Classification: Unclassified
General (Other open bugs)
core-(2.0)
All All
: Unprioritized normal
: ---
Assigned To: Pywikipedia bugs
backportable
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-28 21:25 UTC by Kunal Mehta (Legoktm)
Modified: 2014-09-18 10:25 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Kunal Mehta (Legoktm) 2013-09-28 21:25:24 UTC
>>> 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%20City&prop=langlinks (the actual API query we make) only returns language codes, not full database names.
Comment 1 Sorawee Porncharoenwase 2014-02-27 20:19:50 UTC
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
Comment 2 Maarten Dammers 2014-02-27 20:25:19 UTC
Commons is a weird wiki. The langlinks point to Wikipedia. That should be the behavior in the bot too.
Comment 3 Gerrit Notification Bot 2014-06-09 07:22:28 UTC
Change 138299 had a related patch set uploaded by John Vandenberg:
Bug 54745: Link.langlinkUnsafe interwiki_forward

https://gerrit.wikimedia.org/r/138299
Comment 4 Gerrit Notification Bot 2014-06-09 07:39:03 UTC
Change 138299 merged by jenkins-bot:
Bug 54745: Link.langlinkUnsafe interwiki_forward

https://gerrit.wikimedia.org/r/138299
Comment 5 Ricordisamoa 2014-06-09 07:59:53 UTC
Should we change this in compat, too?

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links