r10206 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r10205‎ | r10206 | r10207 >
Date:12:59, 19 July 2005
Author:vibber
Status:old
Tags:
Comment:
* Include RPC roundtrip service time in debug log
* Optionally on output
* add 'update' parameter to update or delete an individual page by title
* per-database flush is gone; currently does all only
Modified paths:
  • /trunk/extensions/MWSearch/MWSearchUpdater.php (modified) (history)
  • /trunk/extensions/MWSearch/luceneUpdate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MWSearch/MWSearchUpdater.php
@@ -7,6 +7,7 @@
88
99 $mwSearchUpdateHost = 'localhost';
1010 $mwSearchUpdatePort = 8124;
 11+$mwSearchUpdateDebug = false;
1112
1213 class MWSearchUpdater {
1314 /**
@@ -98,7 +99,7 @@
99100 * @static
100101 */
101102 function sendRPC( $method, $params=array() ) {
102 - global $mwSearchUpdateHost, $mwSearchUpdatePort;
 103+ global $mwSearchUpdateHost, $mwSearchUpdatePort, $mwSearchUpdateDebug;
103104 $client = new XML_RPC_Client( '/SearchUpdater', $mwSearchUpdateHost, $mwSearchUpdatePort );
104105
105106 $rpcParams = array();
@@ -118,9 +119,18 @@
119120
120121 $message = new XML_RPC_Message( $method, $rpcParams );
121122 wfSuppressWarnings();
 123+ $start = wfTime();
122124 $result = $client->send( $message );
 125+ $delta = wfTime() - $start;
123126 wfRestoreWarnings();
124127
 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+
125135 if( !is_object( $result ) ) {
126136 return new WikiError( "Unknown XML-RPC error" );
127137 } elseif( $result->faultCode() ) {
Index: trunk/extensions/MWSearch/luceneUpdate.php
@@ -18,15 +18,16 @@
1919 break;
2020 case 'restart':
2121 case 'flushall':
 22+case 'flush':
2223 $ret = MWSearchUpdater::flushAll();
2324 break;
2425 case 'start':
2526 $ret = MWSearchUpdater::start();
2627 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;
3132 case 'status':
3233 // no-op
3334 $ret = true;
@@ -34,6 +35,19 @@
3536 case 'quit':
3637 $ret = MWSearchUpdater::quit();
3738 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;
3852 case 'rebuild':
3953 $builder = new LuceneBuilder();
4054 if( isset( $options['skip'] ) ) {

Status & tagging log