Difference between revisions of "MediaWikiLite"

From Organic Design wiki
(Current State: www.mediawikilite.org is running the current version of MediaWikiLite)
(comments and ideas about the revision bug)
Line 92: Line 92:
  
 
I've installed SQLite on the server and created an instance of MediaWikiLite at [http://www.mediawikilite.org www.mediawikilite.org]
 
I've installed SQLite on the server and created an instance of MediaWikiLite at [http://www.mediawikilite.org www.mediawikilite.org]
 +
:I'm impressed how much functionality is working! I saw the edit conflict problem. From what I know there could be two potential causes. The HTML code generaton getting the timestamp gateway variable wrong somehow, or the revision key not being handled transparently by sqlLite. The domain is a good idea - I think there will be a lot of interest in this as people click to the potential applications in embedded systems. The performance seems better also. --[[User:Rob|Rob]] 13:25, 12 January 2008 (NZDT)
  
 
== See also ==
 
== See also ==

Revision as of 00:25, 12 January 2008

The idea of MediaWikiLite is to allow the current MediaWiki codebase to run as a standalone server without requiring a database server or web-server. This forms the foundation for a number of alternative uses for the MediaWiki software in enviroments where the current LAMP architecture is too resource intensive.

  • Personal wiki: Personal desktop wiki's are becoming very popular, but they do not use the MediaWiki parser, and making a fork of the parser code defeats the purpose.
  • Embedded devices such as PDA's, iPod's and iPhone's can only run lite applications effectively and getting MediaWiki onto them would be very useful, especially if it's designed to synchronise with a web-based mirror when an internet connection is available.
  • PeerPedia: A lite version of MediaWiki is required to make it a possible candidate for a client side wiki interface to a P2P article space.

This extension creates a new database subclass which allows a MediaWiki to work from an SQLite database instead of MySQL. MySQL is good for large centralised sites serving many clients, but we'd like MediaWiki to be able to run on small local systems such as iPods or iPhones. MySQL is the main obstacle preventing us from creating a light-weight MediaWiki install which would also be a big step towards our Peerpedia idea.

Replacing the Web Server

This may require FastCGI or a similar alternative because there is problems with functions such as header() which have no effect when running from command line but the function still exists so it can't be replaced. Unless there's some way of overriding built-in functions, this may not be possible.

NanoWeb looks like a good solution for the this. It's a web-server entirely written in PHP and comes with a number of modules such as a ReWrite clone. It can execute CGI scripts using a normal CGI module or a FastCGI module. Also the modules looks very easy to write so a module specifically designed to maintain a MediaWiki instance in memory could be written.

SQLite Installation

It's important to have this working with SQLite3 rather than 2 because version 3 supports more similar syntax for some SQL such as table creation than version 2. Aside from that, version 3 uses more compact files and executes more efficiently. SQLite3 works via PHP's PDO functions.

  • To install SQLite3 on a Debian based system, use apt-get install php5-sqlite3.
  • Installer script needs to be patched to allow SQLite to work for a wiki installation since extensions are added from LocalSettings.php

Development Notes

The main include is Extension:MediaWikiLite.php which is added to LocalSettings.php as usual. This then uses the $wgAutoloadClasses array to load DatabaseSqlite.php when required by the LoadBalancer.

I've created a local MediaWiki-1.11 codebase copy that I can modify without affecting other local wikia. The config/index.php MediaWiki install script needs to be hacked to add an SQLite option. I added the following to the end of the $ourdb array:

{{{1}}}

Further down in the config/index.php installer script there is more database specific code for creating an initial MediaWiki database. In the case of MySQL it reads in tables.sql and interwiki.sql from the maintenance dir using the dbsource global function, but if it's PostgreSQL it executes the DatabasePostgresql::setup_database method, and if it's neither it raises an error saying it doesn't know how to handle the database type. I adjusted that code (around line 1000) to make it execute setup_database for all database types that are not MySQL as follows:

{{{1}}}

The setup_database method is done and is successfully creating all the tables as the following output from SQLite3 on the comman line shows:

sqlite> .tables
archive            job                querycache         text             
categorylinks      langlinks          querycache_info    trackbacks       
externallinks      logging            querycachetwo      transcache       
filearchive        math               recentchanges      user             
hitcounter         objectcache        redirect           user_groups      
image              oldimage           revision           user_newtalk     
imagelinks         page               searchindex        watchlist        
interwiki          page_restrictions  site_stats       
ipblocks           pagelinks          templatelinks   

Currently all the INDEX and KEY definitions in the CREATE TABLE statements have been removed, so this may cause problems down the track and need revising by adding CREATE INDEX statements etc.

The tables are being populated with the correct data during the installation as can be seen from the output of the following SELECT queries done from the command line.

sqlite> select * from text;
1|<big>'''MediaWiki has been successfully installed.'''</big>
Consult the [http://meta.wikimedia.org/wiki/Help:Contents User's Guide] for information on using the wiki software.
== Getting started ==
* [http://www.mediawiki.org/wiki/Manual:Configuration_settings Configuration settings list]
* [http://www.mediawiki.org/wiki/Manual:FAQ MediaWiki FAQ]
* [http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]|utf-8

sqlite> select * from revision;
1||||0|MediaWiki default|20080109065800|0|0|449|

Current State

All the tables are created successfully (but indexes may need to be separately created later and NOT NULL's have been removed). The tables are populated with the proper initial data from the install such as user information and the initial main page article text and revision. The site renders, and special pages work, but articles content is not being retrieved, users aren't recognised when logging in and it dies when trying to submit an edit. The screenshot below shows the Special:Version page working successfully.

Mwlite.png

Initial tests are very encouraging - the site is far faster running locally than a MySQL-based MediaWiki - and removing Apache will yield a similar increase! There are currently no database errors produced when submitting an edit, but all pages render as empty (giving the "currently no text in page" message). I thought this meant that article editing was failing since that would likely be the most database intensive part of the procedure, but in fact selecting the content from the page and revision tables shows that the edits are in fact affecting the database. Also, "show changes" and "preview" buttons are working correctly.

sqlite> select * from page;
1|0|Main_Page||0|0|1|0.720675190929|20080109083746|0|0
2|0|Current_events||0|0|1|0.81188573813|20080110050708|0|0
3|0|Current_events||0|0|1|0.580048531823|20080110052929|0|0
4|0|Current_events||0|0|1|0.155152406364|20080110053015|0|0
5|0|Current_events||0|0|1|0.081097315793|20080110053030|0|0
6|0|Main_Page||0|0|1|0.698409093629|20080110053111|0|0

sqlite> select * from revision;
1||||0|MediaWiki default|20080109083746|0|0|449|
2|||New page: gfsgs|0|127.0.0.1|20080110050708|0|0|5|
3|||New page: gfsgs|0|127.0.0.1|20080110052929|0|0|5|
4|||New page: gfsgs|0|127.0.0.1|20080110053015|0|0|5|
5|||New page: dgsdgs|0|127.0.0.1|20080110053030|0|0|6|
6|||sdgsdgs|0|127.0.0.1|20080110053111|0|0|19|

After realising that PDO allows DB::numRows() (number of rows returned by a SELECT query) to be obtained from count(PDO::Statement) many of the problems were resolved. Now we can create new pages, and create new users who can login etc, but edits to existing pages result in a permanant edit conflict condition.

I've installed SQLite on the server and created an instance of MediaWikiLite at www.mediawikilite.org

I'm impressed how much functionality is working! I saw the edit conflict problem. From what I know there could be two potential causes. The HTML code generaton getting the timestamp gateway variable wrong somehow, or the revision key not being handled transparently by sqlLite. The domain is a good idea - I think there will be a lot of interest in this as people click to the potential applications in embedded systems. The performance seems better also. --Rob 13:25, 12 January 2008 (NZDT)

See also