Page MenuHomePhabricator

MediaWiki support for v1.14 broken by paraminfo
Closed, DeclinedPublic

Description

{6e1f391837ea6} broke support for MediaWiki 1.14

$ python pwb.py shell
Welcome to the Pywikibot interactive shell!
>>> s = pywikibot.Site('ar', 'anarchopedia')
>>> p = pywikibot.Page(s, 'main page')
>>> p.text
ERROR: AssertionError: 
Traceback (most recent call last):
...
  File ".../pywikibot/page.py", line 500, in text
    self._text = self.get(get_redirect=True)
  File ".../pywikibot/tools/__init__.py", line 1327, in wrapper
    return obj(*__args, **__kw)
  File ".../pywikibot/page.py", line 367, in get
    self._getInternals(sysop)
  File ".../pywikibot/page.py", line 397, in _getInternals
    self.site.loadrevisions(self, getText=True, sysop=sysop)
  File ".../pywikibot/site.py", line 3713, in loadrevisions
    step=step, total=total, **rvargs)
  File ".../pywikibot/site.py", line 1867, in _generator
    gen = gen_class(type_arg, **req_args)
  File ".../pywikibot/data/api.py", line 2909, in __init__
    QueryGenerator.__init__(self, **kwargs)
  File ".../pywikibot/data/api.py", line 2504, in __init__
    self.site._paraminfo.fetch('query+' + mod for mod in self.modules)
  File ".../pywikibot/data/api.py", line 563, in fetch
    self._init()
  File ".../pywikibot/data/api.py", line 275, in _init
    assert self._action_modules == set(main_modules_param['type'])
AssertionError

The fix is:

diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index c932613..84c1232 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -371,6 +371,8 @@ class ParamInfo(Container):
             ],
         }
 
+        self._add_submodules('main', action_modules)
+
         if _mw_ver >= MediaWikiVersion('1.12'):
             return

Event Timeline

jayvdb claimed this task.
jayvdb raised the priority of this task from to High.
jayvdb updated the task description. (Show Details)
jayvdb added a project: Pywikibot.
jayvdb subscribed.

Change 246174 had a related patch set uploaded (by John Vandenberg):
Fix paraminfo for MediaWiki v1.14

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

This fix is causing a problem in one specific test. My initial impression is that the assertion in the test isnt particularly useful, but it wouldnt be hard to work around it if the assertion is useful.

======================================================================
FAIL: Test init where it first adds query and then main.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/jayvdb/pywikibot-core/tests/api_tests.py", line 192, in test_init_query_first
    pi._init()
  File "/home/travis/build/jayvdb/pywikibot-core/pywikibot/data/api.py", line 251, in _init
    self._parse_help(_mw_ver)
  File "/home/travis/build/jayvdb/pywikibot-core/pywikibot/data/api.py", line 375, in _parse_help
    self._generate_submodules(['main'])
  File "/home/travis/build/jayvdb/pywikibot-core/tests/api_tests.py", line 182, in patched_generate_submodules
    assert 'query' in modules
AssertionError
Xqt subscribed.

As anarchopedias has been closed, we couldn't verify this bug anymore. Also we think about dropping support for older mw versions.

Change 246174 abandoned by Xqt:
Fix paraminfo for MediaWiki v1.14

Reason:
See Task

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