Skip to content

Developer

yannouk edited this page Aug 7, 2012 · 6 revisions

Table of Contents

Project design

From MediaWiki to WikiZam

LocalSettings.php has been split!

  • LocalSettings.php : Application Settings (config, extensions...)
  • ServerSettings.php : Server Settings (dbuser, dbpassword, codes, salt, url config...)

MediaWiki core patches

All patches can be found here There is few MediaWiki patches, mainly to improve user interface. Be carefull when updating MediaWiki. We hope that theses patches will not be required in futurs MW releases, but for now, we need it.

MediaWiki files upload

Configuring-files-upload-and-securing-their-viewing

Colors Layout Design

Color Palette

Some developer'tips

Delete a Git commit

 git rebase --onto XXX~1 XXX

with XXX the commit id (you can get it using git log)

Display MediaWiki errors

  • To have your PHP engine talking more about errors, you can add the following lines in your ServerSettings.php at the beginning, but only while developing on your local machine !!
 error_reporting( E_ALL | E_STRICT );
 ini_set( 'display_errors', 1 );
 $wgShowExceptionDetails = true;

Internationalization (118n)

  • Use the global function wfMessage( $key )
    • This is the new MediaWiki function for getting translated interface messages. The intention is to replace all former wfMsg functions.
    • wfMessage( 'msg-index' )->text() Returns the message text. {{-transformation is done.
    • wfMessage( 'msg-index' )->parse() Fully parse the text from wikitext to HTML
    • wfMessage( 'msg-index' )->plain() Returns the message text as-is, only parameters are subsituted.

Write to a log file

  • You can simply write to log file using a MW global function like this:
 wfDebugLog( 'myLogKey', 'I am somewhere behind the screen' );
  • This will append the sentence I am somewhere behind the screen to the log file of group myLogKey.
  • In ServerSettings.php, you have to set the log groups by setting $wgDebugLogGroups like this:
 $wgDebugLogGroups = array( 'myLogKey' => '/var/log/seizam/myLogFile.txt' );
  • Ensure that the log file you have just set is writable (if it doesn't exist, it will be automatically created)
  • So now, everytime the PHP engine process a call to wfDebugLog( 'myLogKey', ... ), it will write the second argument to the file /var/log/seizam/myLogFile.txt

Get the call stack, using wfGetPrettyBacktrace();

 wfDebugLog( 'myLogKey', "the backtrace is:\n" . wfGetPrettyBacktrace() );
  • will write to the log file:
the backtrace is:
file: /usr/share/seizam/wikizam-0.7/includes/upload/UploadBase.php line: 145 call: seizamGetBacktrace()
file: /usr/share/seizam/wikizam-0.7/includes/api/ApiMain.php line: 342 call: UploadBase->__construct()
file: /usr/share/seizam/wikizam-0.7/api.php line: 115 call: ApiMain->execute()

Log pages

/!\ This has not been used in WikiZam, but we keep it here for reference.

  • Warning, before using this, ensure that custom log pages are supported... It looks like not with a default MW installation.
  • $log = new LogPage( 'wikiplace' );
    • String: one of '', 'block', 'protect', 'rights', 'delete', 'upload', 'move'
    • Boolean: whether to update recent changes as well as the logging table
  • $log->addEntry( 'submitted-datas', $wgUser->getUserPage(), '$theinputbox='.$theinputbox );
    • String: one of , 'block', 'protect', 'rights', 'delete', 'upload', 'move', 'move_redir'
    • Title object
    • String: description associated
    • Array: parameters passed later to wfMsg.* functions
    • User object: the user doing the action
Clone this wiki locally