zhuyifei1999 added a comment.

Looks like a no-op to me.

Scratch that. It is relevant, yes, but the original implementation of using a layer of 'indirectness' is not good.

The bug is caused by the combination of pagegenerators.py#L496 and api.py#L2710:

if isinstance(self.gens[i], pywikibot.data.api.QueryGenerator):
    if self.namespaces:
        self.gens[i].set_namespace(self.namespaces)
    if self.limit:
        self.gens[i].set_maximum_items(self.limit)
else:
    if self.namespaces:
        self.gens[i] = NamespaceFilterPageGenerator(self.gens[i],
                                                    self.namespaces,
                                                    self.site)
    if self.limit:
        self.gens[i] = itertools.islice(self.gens[i], self.limit)

param = self.site._paraminfo.parameter('query+' + self.limited_module,
                                       'namespace')
if not param:
    pywikibot.warning(u'{0} module does not support a namespace '
                      'parameter'.format(self.limited_module))
    return

The caller pagegenerators.py recognizes that it is an API Query generator and therefore asks the generator itself to do the filtering, instead using our own filtering system. This is completely logical, however, querypage MediaWiki API module can't filter by namespace, and the callee api.py just ignored the request, only displaying a warning, leaving the caller pagegenerators.py no way of knowing this fault. I suggest changing this warning to an error/exception; what is asked should be done or let the caller know it's not done, and an exception seems most logical to me.

Yes, having UnconnectedPageGenerator would make api.py think it's not an API Query generator, but in reality it only contributing to code smell.


TASK DETAIL
https://phabricator.wikimedia.org/T196619

EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: zhuyifei1999
Cc: zhuyifei1999, Multichill, gerritbot, matej_suchanek, Xqt, Framawiki, Aklapper, JAnD, pywikibot-bugs-list, Gaboe420, Versusxo, Majesticalreaper22, Giuliamocci, Adrian1985, Cpaulf30, Baloch007, Darkminds3113, Bsandipan, Lordiis, Adik2382, Jrbranaa, Th3d3v1ls, Ramalepe, Liugev6, Magul, Tbscho, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, Avicennasis, Wong128hk, mys_721tx, jayvdb, Ricordisamoa, Dalba, Masti, Alchimista, Rxy
_______________________________________________
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs

Reply via email to