andrew fabbro wrote:
I'm curious if there is any documentation on the
"rules" for updating a
mediawiki SQL database. Specifically, something like "if you want to
delete a page, modify these tables and fields" or "here are the steps to
insert a page into the database".
Not really; there's just the code. In brief, to add a new page:
* Insert a complete record into the cur table. (cur_id is
auto_increment, do not assign a value to it!)
* Insert a summary record into the recentchanges table.
* Update links, brokenlinks, imagelinks, and categorylinks with the
pages that your new page links to.
* Move links from brokenlinks to links if there are existing broken
links to this page.
* Update the cur_touched field of any pages affected by the last step.
* Insert an appropriate record into the searchindex table.
* Update the article count in site_stats if and only if the new article
passes the article count criteria (is in namespace 0, is not a redirect,
and contains at least one instance of the string "[[")
To delete a page:
* Copy the cur and old records into the archive table so it can be
restored if need be
* Delete the records from cur and old.
* Delete the searchindex row.
* Delete summary rows from recentchanges.
* Remove outgoing links from links, brokenlinks, imagelinks, and
categorylinks.
* Move any incoming links from links to brokenlinks.
* Update cur_touched field of any page affected by the last step.
* Add a note to the deletion log page (creating it if necessary)
* Add a recentchanges summary row for the deletion log update
* Update site_stats as for new page, decrementing rather than incrementing.
Updating all these things correctly might be a bit tricky, and you'll
have to update your scripts when the database format changes. You might
consider using a client-side bot to avoid duplicating the whole of
MediaWiki's backend. ;) There's an actively maintained python-based bot
family at
http://pywikipediabot.sf.net
-- brion vibber (brion @
pobox.com)