[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
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 clearCacheStats.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 --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 28 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: 32 33 ==BEGIN== 34 35 <?php 36 37 require_once 'Maintenance.php'; 38 39 class DemoMaint extends Maintenance { 40 41 public function __construct() { 42 parent::__construct(); 43 } 44 45 public function execute() { 46 } 47 } 48 49 $maintClass = "DemoMaint"; 50 require_once RUN_MAINTENANCE_IF_MAIN; 51 52 ==END== 53 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 https://doc.wikimedia.org/mediawiki-core/master/php/html/classMaintenance.html
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |