English Français Deutsch

inc/db.php

The main database code. it creates the global $swDB object and handles all indexes.
It does not handle writing of new records. This is done in inc/record.php. It observes changes and updates indexes based on need.

Note that to look up a record by URL, the indexes are not used. The hashes of the filenames in the current folder are the index for that.

Objects

swDB

Global object, initiated in api.php. It manages and provides on request the following indexes

A valid revision is a revision that is both current and not deleted.

The index files are in the site/indexes folder.

init($force = false) initiates the swDB.
First the bitmaps are read.
If the last revision is 0 or if forced is set (when you request the page Special:Recent Changes, then index are rebuilt.

close() writes down modifications that have been added to the bitmaps.

UpdateIndexes($rev) updates the index for one revision. It sets the bitmaps and writes to the urls.txt file

GetLastRevisionFolderItem() returns the highest revision in the revision folder.

RebuildIndexes() updates indexes each revision at a time. The record lookup by revisions triggers also writing of the record to the current folder. There is a timeout. Normally, one request makes about 5000 revisions.

RebuildBitmaps() can recreate the bitmaps if the urls.txt file is still available.

Functions

swGetAllRevisionsFromName($name) gives back a history of all revisions of a page as a list of revision

swGetPath($revision) returns the path from a revision to its file

File structure inc folder