* (bug 8445) Multiple-character search terms are now handled properly for Chinese
[lhc/web/wiklou.git] / docs / maintenance.txt
1 Prior to version 1.16, maintenance scripts were a hodgepodge of code that
2 had no cohesion or formal method of action. Beginning in 1.16, maintenance
3 scripts have been cleaned up to use a unified class.
4
5 1. Directory structure
6 2. How to run a script
7 3. How to write your own
8
9 1. DIRECTORY STRUCTURE
10 The /maintenance directory of a MediaWiki installation contains several
11 subdirectories, all of which have unique purposes.
12
13 2. HOW TO RUN A SCRIPT
14 Ridiculously simple, just call 'php someScript.php' that's in the top-
15 level /maintenance directory.
16
17 Example:
18 php clear_stats.php
19
20 The following parameters are available to all maintenance scripts
21 --help : Print a help message
22 --quiet : Quiet non-error output
23 --dbuser : The database user to use for the script (if needed)
24 --dbpass : Same as above (if needed)
25
26 3. HOW TO WRITE YOUR OWN
27 Make a file in the maintenance directory called myScript.php or something.
28 In it, write the following:
29
30 ==BEGIN==
31
32 <?php
33
34 require_once( "Maintenance.php" );
35
36 class DemoMaint extends Maintenance {
37
38 public function __construct() {
39 parent::__construct();
40 }
41
42 protected function execute() {
43 }
44 }
45
46 $maintClass = "DemoMaint";
47 require_once( DO_MAINTENANCE );
48
49 ==END==
50
51 That's it. In the execute() method, you have access to all of the normal
52 MediaWiki functions, so you can get a DB connection, use the cache, etc.
53 For full docs on the Maintenance class, see the auto-generated docs at
54 http://svn.wikimedia.org/doc/classMaintenance.html