Prefix parameter to Wiki.listPages predates provided namespace
PeterBowman opened this issue · 2 comments
The namespace parameter is meaningless when a title prefix is provided, see:
wiki-java/src/org/wikipedia/Wiki.java
Lines 6179 to 6185 in 4026210
This behavior might create confusion. I'm used to omitting the Category:
namespace in page titles when using Wiki.categoryMembers
. For the sake of clarity, these are the function's internals:
wiki-java/src/org/wikipedia/Wiki.java
Lines 5664 to 5668 in 4026210
That is, I can invoke wiki.categoryMembers("Foo")
and get all members of Category:Foo
. In that vein, I expected that wiki.listPages("Foo", null, Wiki.CATEGORY_NAMESPACE)
would list all categories starting with Foo
, but it shows results from the main namespace only. The behavior I propose here is also consistent with the Special:ApiSandbox interface, which also expects a namespace-less title prefix along with the actual namespace passed on as another query parameter.
Moreover, namespaces could get "stacked" together, see wikt:es:Categoría:Wikcionario:Esbozo
. Here, the localized Categoría
refers to the category namespace, and Wikcionario
to the project namespace.
Wiki wiki = Wikibot.createInstance("es.wiktionary.org");
String[] titles1 = wiki.listPages("Wikcionario:Esbozo", null, Wiki.CATEGORY_NAMESPACE);
System.out.println(Arrays.asList(titles1)); // [] (apnamespace=4)
String[] titles2 = wiki.listPages("Categoría:Wikcionario:Esbozo", null, Wiki.CATEGORY_NAMESPACE);
System.out.println(Arrays.asList(titles2)); // [Categoría:Wikcionario:Esbozo] (apnamespace=14)
Does #163 fix this? The behavior I want is equivalent to:
https://en.wikipedia.org/wiki/Special:PrefixIndex/Wikipedia:Featured_pictures/
That'll do, thanks! You might want to update docs for the overload of listPages()
, too.