mediawiki icon indicating copy to clipboard operation
mediawiki copied to clipboard

Cannot create redirect

Open Efreak opened this issue 9 years ago • 3 comments

Whenever I try to add a redirect, I get the following error stack. I can create/overwrite a page just fine, however it fails when I set the content to "#REDIRECT [["+message.gamename+"]]" (message.gamename has been sucessfully used previously in the same script as the title of an article, so the problem isn't there). When I escape # with a \, I get the same issue.

TypeError: Cannot read property '0' of undefined
    at /home/efreak/chatbot-efreak/node_modules/mediawiki/mediawiki.js:480:69
    at Array.forEach (native)
    at Bot.<anonymous> (/home/efreak/chatbot-efreak/node_modules/mediawiki/mediawiki.js:477:19)
    at Bot._processResponse (/home/efreak/chatbot-efreak/node_modules/mediawiki/mediawiki.js:227:29)
    at Request._callback (/home/efreak/chatbot-efreak/node_modules/mediawiki/mediawiki.js:179:34)
    at Request.self.callback (/home/efreak/chatbot-efreak/node_modules/request/request.js:121:22)
    at Request.EventEmitter.emit (events.js:98:17)
    at Request.<anonymous> (/home/efreak/chatbot-efreak/node_modules/request/request.js:978:14)
    at Request.EventEmitter.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/home/efreak/chatbot-efreak/node_modules/request/request.js:929:12)

Efreak avatar Sep 20 '14 00:09 Efreak

I am entirely incorrect here. The bot I have created is entirely unable to create new pages at all. Can you possibly tell me what I'm doing wrong here?

The following works:

that.wikiBot.edit("Sandbox", result.text, result.summary).complete(function (title, revision, date) {
                    that._sendMessageAfterDelay(toId, "Revision #" + revision + " completed on " + title + " at " + date.toString() + ".\nPage created/updated for "+result.gamename);
                    console.log("Revision #" + revision + " completed on " + title + " at " + date.toString() + ".\nPage created/updated for "+result.gamename);
                })

This, however, does not work:

that.wikiBot.edit("Sandbox2", result.text, result.summary).complete(function (title, revision, date) {
                    that._sendMessageAfterDelay(toId, "Revision #" + revision + " completed on " + title + " at " + date.toString() + ".\nPage created/updated for "+result.gamename);
                    console.log("Revision #" + revision + " completed on " + title + " at " + date.toString() + ".\nPage created/updated for "+result.gamename);
                })

Efreak avatar Sep 20 '14 01:09 Efreak

@Efreak, are you logged in as a user that can create a page? Many wikis won't let recently-signed-up users or unregistered users create pages. They can, however, edit pages.

Check what is said in the error callback:

that.wikiBot.edit( ... ).error(function (err) {
    console.log(err.toString());
});

oliver-moran avatar Sep 22 '14 14:09 oliver-moran

The bot is unable to create a page because there is no revisions property for a page that doesn't exist. I submitted a pull request that fixes this, along with some readme things. I'm going to submit an issue for some more pre-baked functions

Efreak avatar Sep 24 '14 23:09 Efreak