Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pausing and resuming a Mediawiki edit session

Is it possible to pause and resume a Mediawiki edit?

To explain, I've written a MW extension that accesses an external database; this database requires OAuth authentication, which is a three-step process requiring the user to be redirected to an external site to allow the extension access to the external db. If the MW extension already has an access token for the extDb, all is well. However, if there isn't a token, there is a problem. This is a tag extension, and is triggered by finding a certain XML tag in the wiki page, which typically occurs in the 'preview' or 'submit' of an edit, e.g. http://server.com/wiki/index.php?title=Bibliography&action=submit (the parser hook is ParserFirstCallInit). The callback URL constructed by the OAuth code returns you to the page you were editing, but in its pre-edit state: i.e. you lose all your edits.

How can I resume the edit and not lose my edit data?

like image 451
i alarmed alien Avatar asked Nov 21 '25 07:11

i alarmed alien


1 Answers

You could just use store the data in $_SESSION. MediaWiki itself uses it to store user authentication data, so it should be well integrated with MediaWiki's own session handling.

Note that, by default, MediaWiki doesn't create a session for anonymous users unless they try to log in or do something else that requires a session. If your external authentication code is only meant to be used by logged-in users, this should not be an issue, but just to be safe you may want to make sure that a session is set up before trying to use it:

if ( session_id() == '' ) {
    wfSetupSession();
}
like image 149
Ilmari Karonen Avatar answered Nov 22 '25 23:11

Ilmari Karonen