Extension:Memento

What can this extension do?
The Memento extension implements support of the X-Accept-Datetime HTTP header to perform content negotiation in the date-time dimension, built on the principles of RFC 2295. This enables MediaWiki to be used as a web archive.

The extension works in three simple steps:
 * Checks for the existence of an X-Accept-Datetime header in the client's request.
 * If the X-Accept-Datetime header exists, redirect the client to the version of the requested resource that was the live version at the date-time expressed as the value of the X-Accept-Datetime header.
 * If the X-Accept-Datetime header does not exist, handle the client's request as usual. Nothing out of the ordinary will happen.

This plug-in uses the same handlers that MediaWiki does to connect to the database and hence all the existing database permissions and page access permissions are honored. This plug-in only uses a 'DB_SLAVE' database connection, which means that the database connection can only read from the tables. Hence, this plug-in makes no changes to the database.

Installation
To install this extension, add the following to LocalSettings.php:

Configuration parameters
There are no configuration parameters.

Usage
Once installed, the extension can be tested and used in two ways:

And then look in headers.txt to make sure it looks similar to:
 * 1) Using a Firefox browser: Install the Modify Headers FireFox extension. Then set the X-Accept-Datetime header from the Tools/Modify Headers menu option. The syntax to use is X-Accept-Datetime: {Sat, 03 Oct 2009 10:00:00 GMT}</tt>. Set it to a date-time at which your wiki was already generating history pages. Then enter a URL of a page from your wiki that has associated history pages around the date-time you chose. If all is well you should immediately retrieve the history page that was the active version at the date-time you picked.
 * 2) Using the UNIX command line tool curl</tt>: To achieve the equivalent of (1) using curl, the command would be:

Namespaces
The extension renders the requested page the same way MediaWiki does. It queries the wiki database table page</tt> with the requested title. Both MediaWiki reserved namespaces and custom namespaces are accounted for, by retrieving the namespace_id</tt> from the object $wgTitle</tt>. If the namespace does not exist, then the plug-in treats the namespace also as part of the title. For example, if the requested title is 'Memento:Main_Page', the plugin will first check if a namespace exist for "Memento" and retrieve it's corresponding namespace_id</tt>. It will then query the page</tt> table for the title 'Main_Page' with the namespace_id</tt>. Otherwise, it will treat "Memento" also as part of the title and search the page</tt> table for the title 'Memento:Main_Page'. If the title could not be found in the database, then an HTTP/1.1 404 Not Found</tt> is returned.

Special Pages
Special pages under the URL http://your.wikiserver.here/index.php/Special:SpecialPages do not have a history, i.e. there are no revisions to these pages. Hence, the Memento extension will return an HTTP/1.1 406 Not Acceptable</tt>.

Deleted Contributions
To do date-time negotiations for the deleted revisions in MediaWiki, most installations require "Administrator" privileges. Even with administrative access, MediaWiki can only show the revisions in "Edit" mode. Hence, this extension currently does not support deleted revisions of articles and an HTTP/1.1 406 Not Acceptable</tt> is returned. However, if a wiki installation requires "Time Travel" to these deleted pages, the following snippet will implement it. Please keep in mind that the code above is not stand-alone and should be used with the original extension plug-in to make it work.