Add .php5 entry for mwScriptLoader.
[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 * @file
13 * @ingroup 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.' . wfWikiId() . '.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 } elseif( is_readable( 'searchUpdate.pos' ) ) {
37 # B/c to the old position file name which was hardcoded
38 # We can safely delete the file when we're done though.
39 $start = file_get_contents( 'searchUpdate.pos' );
40 unlink( 'searchUpdate.pos' );
41 } else {
42 $start = @file_get_contents( $posFile );
43 if ( !$start ) {
44 $start = wfTimestamp( TS_MW, time() - 86400 );
45 }
46 }
47
48 if ( isset( $options['l'] ) ) {
49 $lockTime = $options['l'];
50 } else {
51 $lockTime = 20;
52 }
53
54 $quiet = (bool)(@$options['q']);
55
56 updateSearchIndex( $start, $end, $lockTime, $quiet );
57
58 $file = fopen( $posFile, 'w' );
59 fwrite( $file, $end );
60 fclose( $file );
61
62