Periodic searchindex updates
[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 $optionsWithArgs = array( 's', 'e', 'p' );
13
14 require_once( 'commandLine.inc' );
15 require_once( 'updateSearchIndex.inc' );
16
17 if ( isset( $options['p'] ) ) {
18 $posFile = $options['p'];
19 } else {
20 $posFile = 'searchUpdate.pos';
21 }
22
23 if ( isset( $options['e'] ) ) {
24 $end = $options['e'];
25 } else {
26 $end = wfTimestampNow();
27 }
28
29 if ( isset( $options['s'] ) ) {
30 $start = $options['s'];
31 } else {
32 $start = @file_get_contents( $posFile );
33 if ( !$start ) {
34 $start = wfUnix2Timestamp( time() - 86400 );
35 }
36 }
37
38 if ( isset( $options['l'] ) ) {
39 $lockTime = $options['l'];
40 } else {
41 $lockTime = 20;
42 }
43
44 $quiet = (bool)(@$options['q']);
45
46 updateSearchIndex( $start, $end, $lockTime, $quiet );
47
48 $file = fopen( $posFile, 'w' );
49 fwrite( $file, $end );
50 fclose( $file );
51
52 ?>