3 * Script for periodic off-peak updating of the search index
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
13 * @ingroup Maintenance
17 $optionsWithArgs = array( 's', 'e', 'p' );
19 require_once( 'commandLine.inc' );
20 require_once( 'updateSearchIndex.inc' );
22 if ( isset( $options['p'] ) ) {
23 $posFile = $options['p'];
25 $posFile = 'searchUpdate.' . wfWikiId() . '.pos';
28 if ( isset( $options['e'] ) ) {
31 $end = wfTimestampNow();
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' );
42 $start = @file_get_contents
( $posFile );
44 $start = wfTimestamp( TS_MW
, time() - 86400 );
48 if ( isset( $options['l'] ) ) {
49 $lockTime = $options['l'];
54 $quiet = (bool)(@$options['q']);
56 updateSearchIndex( $start, $end, $lockTime, $quiet );
58 $file = fopen( $posFile, 'w' );
59 fwrite( $file, $end );