Page MenuHomePhabricator

Skip the paraminfo new mode test on sites which do not support the new mode
Closed, ResolvedPublic

Description

The MediaWiki API has two modes of obtaining API parameter information.

The 'old way' was deprecated in WM API version '1.25wmf4' , forcing the dev team to write code to support the new mode, and make that the default for 1.25wmf4+

The test api_tests.TestParamInfo currently runs the 'new mode' tests against any wiki. We need to determine when the new mode was first added to the API, and not run this test for wikis that do not support it.

And, the documentation should be updated with information about the two modes and which versions use which modes: https://www.mediawiki.org/wiki/API:Parameter_information

Event Timeline

jayvdb assigned this task to Omegat.
jayvdb raised the priority of this task from to Needs Triage.
jayvdb updated the task description. (Show Details)
jayvdb changed Security from none to None.
jayvdb added subscribers: Unknown Object (MLST), jayvdb, XZise.

It seems that the new mode was added in version 1.23.
A version 1.22 site
https://frack.nl/w/api.php?action=paraminfo&modules=query+info
https://frack.nl/w/api.php?action=paraminfo&querymodules=info

A version 1.23 site
http://barterempire.gamepedia.com/api.php?actions=paraminfo&modules=query+info

A version 1.24 site
http://baseballpedia.shoutwiki.com/w/api.php?actions=paraminfo&modules=query+info

For 1.23 and 1.24, the action parameter is unrecognized.. I dont know why though.. but the new method is working on 1.23 onwards.

Also, the documentation page needs to be updated but there's no mention of the new mode in it. I am not sure if I know everything to write the documentation for this page.

Your commands are wrong: You need to use action=paraminfo.

Change 181720 had a related patch set uploaded (by Maverick):
Bug: T77966 Skip test_new_mode if the mw version < 1.23. Bug: T77966

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

Patch-For-Review

@Omegat, as @XZise has said, your URLs are wrong. The MediaWiki API is just plain old HTTP. If you cant get it to work in a web browser, it will not work in pywikibot. 1.23.8 (*.gamepedia.com) does not support the new mode.

1.23

http://barterempire.gamepedia.com/api.php?action=query&meta=siteinfo

<?xml version="1.0"?>
<api>
  <query>
    <general mainpage="Barter Empire Wiki" base="http://barterempire.gamepedia.com/Barter_Empire_Wiki" sitename="Barter Empire Wiki" logo="http://hydra-media.cursecdn.com/barterempire.gamepedia.com/b/bc/Wiki.png" generator="MediaWiki 1.23.8" phpversion="5.4.28-1+deb.sury.org~precise+1" phpsapi="fpm-fcgi" dbtype="mysql" dbversion="5.5.31-55" imagewhitelistenabled="" langconversion="" titleconversion="" linkprefixcharset="" linkprefix="" linktrail="/^([a-z]+)(.*)$/sD" git-hash="cf64e03e367f4ce136933709c86dcf9a75969a4b" case="first-letter" lang="en" fallback8bitEncoding="windows-1252" writeapi="" timezone="UTC" timeoffset="0" articlepath="/$1" scriptpath="" script="/index.php" server="http://barterempire.gamepedia.com" wikiid="barterempire_gamepedia" time="2014-12-24T07:58:36Z" maxuploadsize="104857600" favicon="http://hydra-media.cursecdn.com/barterempire.gamepedia.com/6/64/Favicon.ico">
      <fallback />
      <thumblimits>
        <limit>120</limit>
        <limit>150</limit>
        <limit>180</limit>
        <limit>200</limit>
        <limit>250</limit>
        <limit>300</limit>
      </thumblimits>
      <imagelimits>
        <limit width="320" height="240" />
        <limit width="640" height="480" />
        <limit width="800" height="600" />
        <limit width="1024" height="768" />
        <limit width="1280" height="1024" />
      </imagelimits>
    </general>
  </query>
</api>

http://barterempire.gamepedia.com/api.php?action=paraminfo&modules=query+info

<?xml version="1.0"?>
<api>
  <warnings>
    <paraminfo xml:space="preserve">Unrecognized value for parameter 'modules': query info</paraminfo>
  </warnings>
  <paraminfo>
    <modules />
  </paraminfo>
</api>

Using percent encoding of the + doesnt help:

http://barterempire.gamepedia.com/api.php?action=paraminfo&modules=query%2Binfo

<?xml version="1.0"?>
<api>
  <warnings>
    <paraminfo xml:space="preserve">Unrecognized value for parameter 'modules': query+info</paraminfo>
  </warnings>
  <paraminfo>
    <modules />
  </paraminfo>
</api>

And most importantly, the new mode test fails on this site, so it does not work on 1.23!

$ python pwb.py generate_family_file.py http://barterempire.gamepedia.com/ barterempire
Generating family file from http://barterempire.gamepedia.com/

==================================
api url: http://barterempire.gamepedia.com/api.php
MediaWiki version: 1.23.8
==================================

Determining other languages...
Loading wikis... 
  * en... in cache
Writing pywikibot/families/barterempire_family.py... 
$ gedit user-config.py
$ python -m unittest -v tests.api_tests.TestParamInfo
max_retries reduced from 25 to 1 for tests
test_generators (tests.api_tests.TestParamInfo) ... ok
test_init (tests.api_tests.TestParamInfo) ... ok
test_init_pageset (tests.api_tests.TestParamInfo) ... ok
test_modules (tests.api_tests.TestParamInfo)
Test v1.8 modules exist. ... ok
test_multiple_modules (tests.api_tests.TestParamInfo) ... ok
test_new_mode (tests.api_tests.TestParamInfo) ... WARNING: API warning (paraminfo): Unrecognized value for parameter 'modules': main
FAIL
test_old_mode (tests.api_tests.TestParamInfo) ... ok
test_prefixes (tests.api_tests.TestParamInfo)
Test v1.8 module prefixes exist. ... ok
test_query_modules_with_limits (tests.api_tests.TestParamInfo) ... ok
test_with_invalid_module (tests.api_tests.TestParamInfo) ... WARNING: API warning (paraminfo): Unrecognized value for parameter 'modules': foobar
ok
test_with_module_info (tests.api_tests.TestParamInfo) ... ok
test_with_module_revisions (tests.api_tests.TestParamInfo) ... ok

======================================================================
FAIL: test_new_mode (tests.api_tests.TestParamInfo)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/api_tests.py", line 233, in test_new_mode
    pi.fetch(['info'])
  File "pywikibot/data/api.py", line 268, in fetch
    self._init()
  File "pywikibot/data/api.py", line 202, in _init
    main_modules_param = self.parameter('main', 'action')
  File "pywikibot/data/api.py", line 379, in parameter
    self.fetch(set([module]))
  File "pywikibot/data/api.py", line 281, in fetch
    assert(self._query_modules or _init)
AssertionError

----------------------------------------------------------------------
Ran 12 tests in 12.518s

1..24

It also does not work on 1.24

$ python pwb.py generate_family_file.py http://baseballpedia.shoutwiki.com/ baseballpedia
Generating family file from http://baseballpedia.shoutwiki.com/

==================================
api url: http://baseballpedia.shoutwiki.com/w/api.php
MediaWiki version: 1.24.1
==================================

Determining other languages...
Loading wikis... 
  * ru... in cache
Writing pywikibot/families/baseballpedia_family.py... 

$ python -m unittest -v tests.api_tests.TestParamInfo
max_retries reduced from 25 to 1 for tests
test_generators (tests.api_tests.TestParamInfo) ... ok
test_init (tests.api_tests.TestParamInfo) ... ok
test_init_pageset (tests.api_tests.TestParamInfo) ... ok
test_modules (tests.api_tests.TestParamInfo)
Test v1.8 modules exist. ... ok
test_multiple_modules (tests.api_tests.TestParamInfo) ... ok
test_new_mode (tests.api_tests.TestParamInfo) ... WARNING: API warning (paraminfo): Unrecognized value for parameter 'modules': main
FAIL
test_old_mode (tests.api_tests.TestParamInfo) ... ok
test_prefixes (tests.api_tests.TestParamInfo)
Test v1.8 module prefixes exist. ... ok
test_query_modules_with_limits (tests.api_tests.TestParamInfo) ... ok
test_with_invalid_module (tests.api_tests.TestParamInfo) ... WARNING: API warning (paraminfo): Unrecognized value for parameter 'modules': foobar
ok
test_with_module_info (tests.api_tests.TestParamInfo) ... ok
test_with_module_revisions (tests.api_tests.TestParamInfo) ... ok

======================================================================
FAIL: test_new_mode (tests.api_tests.TestParamInfo)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/api_tests.py", line 233, in test_new_mode
    pi.fetch(['info'])
  File "pywikibot/data/api.py", line 268, in fetch
    self._init()
  File "pywikibot/data/api.py", line 202, in _init
    main_modules_param = self.parameter('main', 'action')
  File "pywikibot/data/api.py", line 379, in parameter
    self.fetch(set([module]))
  File "pywikibot/data/api.py", line 281, in fetch
    assert(self._query_modules or _init)
AssertionError

----------------------------------------------------------------------
Ran 12 tests in 14.438s

FAILED (failures=1)

http://baseballpedia.shoutwiki.com/w/api.php?action=paraminfo&modules=query+info
http://baseballpedia.shoutwiki.com/w/api.php?action=paraminfo&modules=query%2Binfo

1.25

It does work on the WMF projects, because they are running 1.25.

https://en.wikipedia.org/w/api.php?action=paraminfo&modules=query%2Binfo

Here is the change which introduced the new mode.

https://gerrit.wikimedia.org/r/#/c/160798/

The WMF team has not added it to the release notes on the wiki

https://www.mediawiki.org/wiki/MediaWiki_1.25

But it is mentioned in their release notes in Git.

https://git.wikimedia.org/blob/mediawiki%2Fcore.git/master/RELEASE-NOTES-1.25

Change 181720 had a related patch set uploaded (by Maverick):
Bug: T77966 Skip test_new_mode if the mw version < 1.25. Bug: T77966

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

Patch-For-Review

Before submitting more incorrect patches, lets discuss the problems here on Phab until you've found a solution that works correctly.

do you know if the version "1.25wmf1" supports the new mode?

'wmf1' is the same as 'alpha', so you can test wmf1 using any of these wikis.

https://wikiapiary.com/wiki/Generator:MediaWiki_1.25alpha

Report the results of the tests here on Phab.

Ok, so 'alpha' is more complicated than 'equals wmf1'

Here are two '1.25alpha' which fail

https://secure.unrelated.net.au/wiki/api.php?action=paraminfo&modules=query+info

http://aniwiki.net/api.php?action=paraminfo&modules=query+info

'alpha' is a version string that is initially 'equals wmf1' , but if the wiki is using git, they can be using code which is more recent, and the version string will still be 'alpha'.

e.g.

https://secure.unrelated.net.au/wiki/api.php?action=query&meta=siteinfo says it is using git-hash="1a239219eebbb53b42d63cb27c20cf0c9a756809" git-branch="master"

http://git.wikimedia.org/tree/mediawiki%2Fcore.git/1a239219eebbb53b42d63cb27c20cf0c9a756809 was dated 2014-09-22

and

http://aniwiki.net/api.php?action=query&meta=siteinfo says it is using git-hash="8aaf4468411b77b3bff93302f8da5815744673ff" git-branch="master"

http://git.wikimedia.org/tree/mediawiki%2Fcore.git/8aaf4468411b77b3bff93302f8da5815744673ff is dated 2014-10-01

https://www.mediawiki.org/wiki/MediaWiki_1.25/wmf3 says wmf3 was released 2014-10-09

As this is quite complicated to detect which wmf version this appeared on, the answer is 1.25wmf4. The new mode feature was added in https://gerrit.wikimedia.org/r/#/c/160798/ , and the old mode was deprecated in the same change.

Change 181720 had a related patch set uploaded (by Maverick):
Skip test_new_mode if the mw version < 1.25wmf4.

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

Patch-For-Review

jayvdb renamed this task from Determine when the new mode of paraminfo became available to Skip the paraminfo new mode test on sites which do not support the new mode.Dec 27 2014, 4:55 AM

Change 181720 merged by jenkins-bot:
Skip test_new_mode if the mw version < 1.25wmf4

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