From 72652c4bc72e7043f3bf12b71abc959510132b5d Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sat, 26 Jun 2004 03:27:08 +0000 Subject: [PATCH] Periodic searchindex updates --- maintenance/updateSearchIndex.inc | 77 +++++++++++++++++++++++++++++++ maintenance/updateSearchIndex.php | 52 +++++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 maintenance/updateSearchIndex.inc create mode 100644 maintenance/updateSearchIndex.php diff --git a/maintenance/updateSearchIndex.inc b/maintenance/updateSearchIndex.inc new file mode 100644 index 0000000000..1adeeb5251 --- /dev/null +++ b/maintenance/updateSearchIndex.inc @@ -0,0 +1,77 @@ + $lockTime + $maxLockTime ) { + output( "Relocking..." ); + relockSearchindex(); + $lockTime = time(); + output( "\n" ); + } + # Get cur row + $curRow = wfGetArray( 'cur', array( 'cur_namespace', 'cur_title', 'cur_text' ), array( 'cur_id' => $row->rc_cur_id ) ); + if ( $curRow ) { + $titleObj = Title::makeTitle( $curRow->cur_namespace, $curRow->cur_title ); + $title = $titleObj->getPrefixedDBkey(); + output( "$title ..." ); + # Update searchindex + $u = new SearchUpdate( $row->rc_cur_id, $curRow->cur_title, $curRow->cur_text ); + $u->doUpdate(); + output( "\n" ); + } + } + + # Unlock searchindex + if ( $maxLockTime ) { + unlockSearchindex(); + } + output( "Done\n" ); +} + +function lockSearchindex() { + wfQuery( "LOCK TABLES searchindex LOW_PRIORITY WRITE, cur READ", DB_WRITE ); +} + +function unlockSearchindex() { + wfQuery( "UNLOCK TABLES", DB_WRITE ); +} + +# Unlock and lock again +# Since the lock is low-priority, queued reads will be able to complete +function relockSearchindex() { + unlockSearchindex(); + lockSearchindex(); +} + +function output( $text ) { + global $wgQuiet; + if ( !$wgQuiet ) { + print $text; + } +} + +?> diff --git a/maintenance/updateSearchIndex.php b/maintenance/updateSearchIndex.php new file mode 100644 index 0000000000..75b789e785 --- /dev/null +++ b/maintenance/updateSearchIndex.php @@ -0,0 +1,52 @@ + -- 2.20.1