You are viewing Revision 1 of Considerations_for_moving_to_a_DB_back-end

Aneuch initially used, and likely always will use, a flat-file storage mechanism for is pages. However, it may be necessary at some point for an administrator to use a database back-end for his wiki.

It is my intent to develop a plugin to allow Aneuch to use a database as its back-end sometime in the near future. However, I will likely only write a plugin to use MySQL. The purpose of this page is two-fold. Firstly, to document the development of this MySQL plugin, and secondly, to document the internal workings of Aneuch that need to be modified by any plugin that wishes to implement its own database system.

Expectations of Aneuch

GetPage

Aneuch calls GetPage to read a page and its associated metadata from the page database. GetPage is expected to return a hash element which includes the contents of the page. They are (as of 0.30):

  • revision - The revision number of the page (begins at 1)
  • summary - The edit summary included by the author
  • text - The text of the page itself (markup, contents, etc)
  • ts - The timestamp of the page, in seconds since the epoch
  • ip - The IP address of the author
  • diff - The output from diff of the current revision in comparison to the previous
  • author - The user name of the author

The table you store your pages in must have these columns in it. Revision is probably good as an integer. Summary and text should be varchar's or maybe just longtext. Ts will likely need to be a bigint. Ip can be a varchar(16) or just char(15). Diff should be longtext, and author can be something like varchar(31) or similar.

WritePage

[WritePage?] is used to store data to a page. It accepts these arguments, in order:

  • $file - The name of the file to write (no directories, only the bare file name)
  • $content - The contents of the page (markup, etc)
  • $user - The author making the modification

WritePage will figure out all the rest of the information it needs (like timestamp, diff, ip, revision number). Obviously, if you replace this function, that will be your job to code those things. Feel free to look into the core Aneuch source to see what it does.

Depending on the table layout you choose (see above for details) you will have to code this function to write out the data in that table layout.