summaryrefslogtreecommitdiff
path: root/maintenance/populateCategory.php
blob: cb22e7f8df5fe51992524fb7617672b8503a3af2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
 * @file 
 * @ingroup Maintenance
 * @author Simetrical
 */

$optionsWithArgs = array( 'begin', 'max-slave-lag', 'throttle' );

require_once "commandLine.inc";
require_once "populateCategory.inc";

if( isset( $options['help'] ) ) {
	echo <<<TEXT
This script will populate the category table, added in MediaWiki 1.13.  It will
print out progress indicators every 1000 categories it adds to the table.  The
script is perfectly safe to run on large, live wikis, and running it multiple
times is harmless.  You may want to use the throttling options if it's causing
too much load; they will not affect correctness.

If the script is stopped and later resumed, you can use the --begin option with
the last printed progress indicator to pick up where you left off.  This is
safe, because any newly-added categories before this cutoff will have been
added after the software update and so will be populated anyway.

When the script has finished, it will make a note of this in the database, and
will not run again without the --force option.

Usage:
    php populateCategory.php [--max-slave-lag <seconds>] [--begin <name>]
[--throttle <seconds>] [--force]

    --begin: Only do categories whose names are alphabetically after the pro-
vided name.  Default: empty (start from beginning).
    --max-slave-lag: If slave lag exceeds this many seconds, wait until it
drops before continuing.  Default: 10.
    --throttle: Wait this many milliseconds after each category.  Default: 0.
    --force: Run regardless of whether the database says it's been run already.
TEXT;
	exit( 0 );
}

$defaults = array(
	'begin' => '',
	'max-slave-lag' => 10,
	'throttle' => 0,
	'force' => false
);
$options = array_merge( $defaults, $options );

populateCategory( $options['begin'], $options['max-slave-lag'],
	$options['throttle'], $options['force'] );