Page MenuHomePhabricator

MediaWiki api.php's search query module requires explicitly listing all values for srnamespace parameter
Closed, ResolvedPublic

Description

So looking at https://commons.wikimedia.org/w/api.php?action=help&modules=query+search:

srnamespace

    Search only within these namespaces. 

    Values (separate with |): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 100, 101, 102, 103, 104, 105, 106, 107, 460, 461, 490, 491, 828, 829, 1198, 1199, 2300, 2301, 2302, 2303, 2600

    Default: 0

Is there a way to search all namespaces? index.php can with profile=all, but it doesn't look like srnamespace has equivalent functionality. Similar to how we support a value of max in parts of the API, it might be nice to have an all-type value accepted for srnamespace.

Event Timeline

MZMcBride raised the priority of this task from to Needs Triage.
MZMcBride updated the task description. (Show Details)
MZMcBride added a project: MediaWiki-API.
MZMcBride added a subscriber: MZMcBride.
Restricted Application added subscribers: StudiesWorld, Aklapper. · View Herald TranscriptJan 19 2016, 5:29 AM
Anomie triaged this task as Lowest priority.Jan 19 2016, 3:36 PM
Anomie set Security to None.
Anomie moved this task from Unsorted to Needs Code on the MediaWiki-API board.
Anomie added a subscriber: Anomie.Jan 19 2016, 3:38 PM

Note if anyone decides to try this, your approach should be to look at the handling of the namespace parameter in ApiBase rather than looking at ApiSearch.

Is there a way to search all namespaces?

Yes, by specifying all the values, separated by pipes. The list of valid values may be fetched in a machine-readable format using action=paraminfo.

Unicornisaurous added a subscriber: Unicornisaurous.

I'll do this

Change 292527 had a related patch set uploaded (by Unicornisaurous):
Add 'all' option for namespace API parameters

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

Anomie moved this task from Needs Code to Blocked on the MediaWiki-API board.Aug 24 2016, 3:45 PM
Anomie moved this task from Blocked to Needs Review on the MediaWiki-API board.Oct 31 2016, 5:29 PM

Change 292527 merged by jenkins-bot:
Add PARAM_ALL setting for multi-option API parameters

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

Anomie closed this task as Resolved.Nov 23 2016, 7:13 PM

Nice. Thank you, Anomie and Unicornisaurous!