Page MenuHomePhabricator

Multiple namespaces aren't recognized
Closed, ResolvedPublic

Description

When I'm using the replace script to go through all pages in several namespaces it only searches through the first:

python pwb.py replace Planetbox "Infobox/Body" -namespace:1,3,4,11 -start:!

When I remove 1, it now searches through namespace 3.

Event Timeline

XZise raised the priority of this task from to Needs Triage.
XZise updated the task description. (Show Details)
XZise changed Security from none to None.
XZise subscribed.

I get the following:

File "/home/user/python/core/pywikibot/pagegenerators.py", line 1276, in PreloadingGenerator
  for page in generator:
File "/home/user/python/core/pywikibot/data/api.py", line 1468, in __iter__
  self.data = self.request.submit()
File "/home/user/python/core/pywikibot/data/api.py", line 1071, in submit
  raise APIError(code, info, **result["error"])
pywikibot.data.api.APIError: gapmultival_gapnamespace: Only one of '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '100', '101', '102', '103', '104', '105', '106', '107', '114', '115', '828', '829' is allowed for parameter 'gapnamespace'

Ah newer versions of MediaWiki apparently throw an error actively:

I haven't actually checked if at some point it'll return pages from the namespace 4 or if that values is ignored (although the OP indicates that it is ignored). Just to be clear, I was using the 1.21 wiki when I executed above command.

For some queries, namespace can assume a single value, for others it can be a list.
See http://en.wikipedia.org/w/api.php?action=help&recursivesubmodules=1#query+allpages for single value.
See https://en.wikipedia.org/w/api.php?action=help&modules=query%2Bbacklinks for multiple values.

class Paraminfo is already understanding if "namespace" is single or multi.
This should be used in api.set_namespace when setting namespace for a QueryGenerator.

Change 178709 had a related patch set uploaded (by XZise):
[FIX] Allow multiple namespaces if available

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

Patch-For-Review

Change 178709 merged by jenkins-bot:
[FIX] Allow multiple namespaces if available

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

Mpaa claimed this task.