Help save net neutrality! Learn more.

#24 AllPageTitles ignores 'from' parameter


Low priority.
Constructor protected AllPageTitles(MediaWikiBot bot, String from, String prefix, RedirectFilter rf, String namespaces) calls generateRequest(from, prefix, rf, namespaces) in line 140. IMHO this call is useless since its return value is discarded and the function itself does not manipulate any data outside its body,

Patch: remove call.


  • jwd

    jwd - 2010-12-14

    Update description!

    It is not possible to start iterating over all page titles from a given title. Example:
    MediaWikiBot bot = new MediaWikiBot("");
    AllPageTitles apt = new AllPageTitles(bot, "!WOWOW!", null, RedirectFilter.all, MediaWiki.NS_MAIN);
    for (String articleName : apt) {

    output starts with page titles '!', '!!', '!!!' instead of '!WOWOW!' as expected.

    Background: (jwbf-1.3.3-298). The String from in constructor should be used to get all page titles starting with this page. In generateRequest(String from, String prefix, RedirectFilter rf, String namespace), it is used to a) start from this page title for the first request and b) used to iterate over a paged result from the api to continue from this page.

    Problem: generateRequest([...]) is called from constructor and by prepareCollection(), but the constructor's call in line 140 is discarded. When iterating over all page titles as in example, prepareCollection() calls generateRequest(getNextPageInfo(), prefix, rf, namespaces) so the from parameter to start from is never used.

    Workaround: add boolean to distinguish between first call and additional calls to process paged results, us it in prepareCollection(). May be there is a better solution but it works for me.

    /** distinguish between first call and additional calls to process paged results */
    private boolean isFirstCall = true;

    protected HttpAction prepareCollection() {
    if (isFirstCall) {
    isFirstCall = false;
    return generateRequest(from, prefix, rf, namespace);
    } else {
    return generateRequest(getNextPageInfo(), prefix, rf, namespace);

  • jwd

    jwd - 2010-12-14
    • summary: AllPageTitles useless call generateRequest --> AllPageTitles ignores 'from' parameter

Log in to post a comment.