jayvdb created this task.
jayvdb assigned this task to XZise.
jayvdb added a subscriber: jayvdb.
jayvdb added a project: pywikibot-core.
Herald added subscribers: pywikibot-bugs-list, Aklapper.

TASK DESCRIPTION
  Steps to reproduce:
  1. disable API caching (e.g. set API_config_expiry = 0)
  2. log into a Site object - this will cause a logged in paraminfo to be 
loaded, which means purge paraminfo does not include `mustbeposted` - see 
62216932c
  3. invalidate that cookie, such as by logging out in another session
  4. call `APISite.purgepages`
  
  Expected results:
  page purge occurs normally
  
  Actual results:
  API complains that purge must be posted
  
  ```
  $ python pwb.py shell
  Welcome to the Pywikibot interactive shell!
  >>> pywikibot._sites = {}
  >>> s = pywikibot.Site('en', 'wikipedia')
  >>> pywikibot.config.API_config_expiry = 0
  >>> s.login()
  >>> 'mustbeposted' in s._paraminfo['purge']
  False
  >>> s.logged_in()
  True
  >>> pywikibot._sites = {}  # allow a new (uncached) Site object to be created
  >>> pywikibot.Site('en', 'wikipedia').logout()  # log out of new site object
  >>> s.purgepages(pages='User:Example')  # re-use original site object
  Traceback (most recent call last):
    File "<console>", line 1, in <module>
    File ".../pywikibot/site.py", line 1165, in callee
      return fn(self, *args, **kwargs)
    File ".../pywikibot/site.py", line 5076, in purgepages
      result = req.submit()
    File ".../pywikibot/data/api.py", line 2102, in submit
      raise APIError(**result['error'])
  APIError: mustbeposted: The purge module requires a POST request
  ```
  
  Behind the scenes,
  1. the original site object believes it is logged in, and has paraminfo for a 
logged in user, and `@must_be('user')` on `APISite.purgepages` doesnt force a 
new login.
  2. Inside `purgepages` an API call is constructed using GET instead of POST
  3. The API complains about GET/POST very early in its handler, otherwise 
T108942 would be the error.
  
  There is also a bug in purge prior to 62216932c, in that its paraminfo did 
not ever include `mustbeposted`.

TASK DETAIL
  https://phabricator.wikimedia.org/T108947

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: XZise, jayvdb
Cc: Aklapper, jayvdb, pywikibot-bugs-list, Malyacko



_______________________________________________
pywikibot-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs

Reply via email to