fixed discussion namespace
[lhc/web/wiklou.git] / maintenance / updateSearchIndex.php
1 <?php
2 /**
3 * Script for periodic off-peak updating of the search index
4 *
5 * Usage: php updateSearchIndex.php [-s START] [-e END] [-p POSFILE] [-l LOCKTIME] [-q]
6 * Where START is the starting timestamp
7 * END is the ending timestamp
8 * POSFILE is a file to load timestamps from and save them to, searchUpdate.pos by default
9 * LOCKTIME is how long the searchindex and cur tables will be locked for
10 * -q means quiet
11 *
12 * @package MediaWiki
13 * @subpackage Maintenance
14 */
15
16 /** */
17 $optionsWithArgs = array( 's', 'e', 'p' );
18
19 require_once( 'commandLine.inc' );
20 require_once( 'updateSearchIndex.inc' );
21
22 if ( isset( $options['p'] ) ) {
23 $posFile = $options['p'];
24 } else {
25 $posFile = 'searchUpdate.pos';
26 }
27
28 if ( isset( $options['e'] ) ) {
29 $end = $options['e'];
30 } else {
31 $end = wfTimestampNow();
32 }
33
34 if ( isset( $options['s'] ) ) {
35 $start = $options['s'];
36 } else {
37 $start = @file_get_contents( $posFile );
38 if ( !$start ) {
39 $start = wfTimestamp( TS_MW, time() - 86400 );
40 }
41 }
42
43 if ( isset( $options['l'] ) ) {
44 $lockTime = $options['l'];
45 } else {
46 $lockTime = 20;
47 }
48
49 $quiet = (bool)(@$options['q']);
50
51 updateSearchIndex( $start, $end, $lockTime, $quiet );
52
53 $file = fopen( $posFile, 'w' );
54 fwrite( $file, $end );
55 fclose( $file );
56
57 ?>