Index: trunk/extensions/MWSearch/MWSearchUpdater.php |
— | — | @@ -7,6 +7,7 @@ |
8 | 8 | |
9 | 9 | $mwSearchUpdateHost = 'localhost'; |
10 | 10 | $mwSearchUpdatePort = 8124; |
| 11 | +$mwSearchUpdateDebug = false; |
11 | 12 | |
12 | 13 | class MWSearchUpdater { |
13 | 14 | /** |
— | — | @@ -98,7 +99,7 @@ |
99 | 100 | * @static |
100 | 101 | */ |
101 | 102 | function sendRPC( $method, $params=array() ) { |
102 | | - global $mwSearchUpdateHost, $mwSearchUpdatePort; |
| 103 | + global $mwSearchUpdateHost, $mwSearchUpdatePort, $mwSearchUpdateDebug; |
103 | 104 | $client = new XML_RPC_Client( '/SearchUpdater', $mwSearchUpdateHost, $mwSearchUpdatePort ); |
104 | 105 | |
105 | 106 | $rpcParams = array(); |
— | — | @@ -118,9 +119,18 @@ |
119 | 120 | |
120 | 121 | $message = new XML_RPC_Message( $method, $rpcParams ); |
121 | 122 | wfSuppressWarnings(); |
| 123 | + $start = wfTime(); |
122 | 124 | $result = $client->send( $message ); |
| 125 | + $delta = wfTime() - $start; |
123 | 126 | wfRestoreWarnings(); |
124 | 127 | |
| 128 | + $debug = sprintf( "MWSearchUpdater::sendRPC for %s took %0.2fms\n", |
| 129 | + $method, $delta * 1000.0 ); |
| 130 | + wfDebug( $debug ); |
| 131 | + if( $mwSearchUpdateDebug ) { |
| 132 | + echo $debug; |
| 133 | + } |
| 134 | + |
125 | 135 | if( !is_object( $result ) ) { |
126 | 136 | return new WikiError( "Unknown XML-RPC error" ); |
127 | 137 | } elseif( $result->faultCode() ) { |
Index: trunk/extensions/MWSearch/luceneUpdate.php |
— | — | @@ -18,15 +18,16 @@ |
19 | 19 | break; |
20 | 20 | case 'restart': |
21 | 21 | case 'flushall': |
| 22 | +case 'flush': |
22 | 23 | $ret = MWSearchUpdater::flushAll(); |
23 | 24 | break; |
24 | 25 | case 'start': |
25 | 26 | $ret = MWSearchUpdater::start(); |
26 | 27 | break; |
27 | | -case 'flush': |
28 | | - global $wgDBname; |
29 | | - $ret = MWSearchUpdater::flush( $wgDBname ); |
30 | | - break; |
| 28 | +//case 'flush': |
| 29 | +// global $wgDBname; |
| 30 | +// $ret = MWSearchUpdater::flush( $wgDBname ); |
| 31 | +// break; |
31 | 32 | case 'status': |
32 | 33 | // no-op |
33 | 34 | $ret = true; |
— | — | @@ -34,6 +35,19 @@ |
35 | 36 | case 'quit': |
36 | 37 | $ret = MWSearchUpdater::quit(); |
37 | 38 | break; |
| 39 | +case 'update': |
| 40 | + $title = Title::newFromText( $args[1] ); |
| 41 | + if( is_null( $title ) ) { |
| 42 | + die( "Invalid title\n" ); |
| 43 | + } |
| 44 | + $rev = Revision::newFromTitle( $title ); |
| 45 | + if( $rev ) { |
| 46 | + $text = $rev->getText(); |
| 47 | + $ret = MWSearchUpdater::updatePage( $wgDBname, $title, $text ); |
| 48 | + } else { |
| 49 | + $ret = MWSearchUpdater::deletePage( $wgDBname, $title ); |
| 50 | + } |
| 51 | + break; |
38 | 52 | case 'rebuild': |
39 | 53 | $builder = new LuceneBuilder(); |
40 | 54 | if( isset( $options['skip'] ) ) { |