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.
7 3. How to write your own
10 The /maintenance directory of a MediaWiki installation contains several
11 subdirectories, all of which have unique purposes.
13 2. HOW TO RUN A SCRIPT
14 Ridiculously simple, just call 'php someScript.php' that's in the top-
15 level /maintenance directory.
18 php clearCacheStats.php
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 --conf : Location of LocalSettings.php, if not default
26 --wiki : For specifying the wiki ID
27 --batch-size : If the script supports batch operations, do this many per batch
29 3. HOW TO WRITE YOUR OWN
30 Make a file in the maintenance directory called myScript.php or something.
31 In it, write the following:
37 require_once 'Maintenance.php';
39 class DemoMaint extends Maintenance {
41 public function __construct() {
42 parent::__construct();
45 public function execute() {
49 $maintClass = "DemoMaint";
50 require_once RUN_MAINTENANCE_IF_MAIN;
54 That's it. In the execute() method, you have access to all of the normal
55 MediaWiki functions, so you can get a DB connection, use the cache, etc.
56 For full docs on the Maintenance class, see the auto-generated docs at
57 http://svn.wikimedia.org/doc/classMaintenance.html