Last modified: 2014-09-12 21:41:34 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 T72766, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 70766 - It is using the user configured site, even though another site was requested
It is using the user configured site, even though another site was requested
Status: RESOLVED FIXED
Product: Pywikibot
Classification: Unclassified
General (Other open bugs)
core-(2.0)
All All
: Unprioritized normal
: ---
Assigned To: Pywikipedia bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-09-12 10:36 UTC by Fabian
Modified: 2014-09-12 21:41 UTC (History)
1 user (show)

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


Attachments

Description Fabian 2014-09-12 10:36:54 UTC
In the user-config a specific site is set but via 'pywikibot.getSite' or 'pywikibot.Site' another (unrelated) Site (family) is chosen.

But in fact after a few requests to the unrelated site it's also querying the user configured site. I found this when I was trying to figure out why I got warnings for a complete legit API call.

>>> import pywikibot
>>> wp = pywikibot.getSite("en", "wikipedia")
>>> wp.tokens['edit']
https://en.wikipedia.org/w/api.php
https://en.wikipedia.org/w/api.php
https://en.wikipedia.org/w/api.php
https://en.wikipedia.org/w/api.php
https://en.wikipedia.org/w/api.php
http://wiki.kerbalspaceprogram.com/w/api.php
WARNING: API warning (query): Unrecognized value for parameter 'meta': tokens
WARNING: API warning (main): Unrecognized parameter: 'type'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pywikibot/site.py", line 1200, in __getitem__
    return storage[key]
KeyError: 'csrf'

If I change the user configuration to the English Wikipedia all api.php calls vanish except one to en.wikipedia.org and I get a legit result.

Each URI is directly printed in the first line threadedhttp's Http.request method.
Comment 1 Fabian 2014-09-12 10:44:58 UTC
Okay a bit more output:

wikipedia:en
/w/api.php
maxlag=5&format=json&meta=siteinfo%7Cuserinfo&action=query&siprop=namespaces%7Cnamespacealiases%7Cgeneral&uiprop=blockinfo%7Chasmsg

wikipedia:en
/w/api.php
action=query&format=json&meta=userinfo&maxlag=5&uiprop=blockinfo%7Cgroups%7Chasmsg%7Crights

wikipedia:en
/w/api.php
action=query&format=json&meta=userinfo&maxlag=5&uiprop=blockinfo%7Cgroups%7Chasmsg%7Crights

wikipedia:en
/w/api.php
action=query&format=json&meta=userinfo&maxlag=5&uiprop=blockinfo%7Cgroups%7Chasmsg%7Crights

wikipedia:en
/w/api.php
maxlag=5&format=json&meta=siteinfo%7Cuserinfo&action=query&siprop=general&uiprop=blockinfo%7Chasmsg

ksp:en
/w/api.php
maxlag=5&format=json&meta=tokens%7Cuserinfo&action=query&type=csrf&uiprop=blockinfo%7Chasmsg

This is now directly above the assert in request of the http module. It prints the URI (always relative) the site (enwp except for the last) and the paramstring.
Comment 2 Mpaa 2014-09-12 18:05:27 UTC
Tried to reproduce, no success so far.
Comment 3 Gerrit Notification Bot 2014-09-12 19:48:03 UTC
Change 159991 had a related patch set uploaded by XZise:
[FIX] Tokens: Return the csrf token and request correct site

https://gerrit.wikimedia.org/r/159991
Comment 4 Gerrit Notification Bot 2014-09-12 21:01:38 UTC
Change 159991 merged by jenkins-bot:
[FIX] Tokens: Return the csrf token and request correct site

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

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


Navigation
Links