Index: trunk/extensions/MWSearch/MWSearchUpdater.php |
— | — | @@ -150,7 +150,7 @@ |
151 | 151 | $translated = array_map( array( 'MWSearchUpdater', 'outParam' ), $param ); |
152 | 152 | return new XML_RPC_Value( $translated, $type ); |
153 | 153 | } else { |
154 | | - return new WikiError( 'MWSearchUpdater::sendRPC given bogus parameter' ); |
| 154 | + throw new MWException( 'MWSearchUpdater::sendRPC given bogus parameter' ); |
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
— | — | @@ -182,9 +182,9 @@ |
183 | 183 | } |
184 | 184 | |
185 | 185 | if( !is_object( $result ) ) { |
186 | | - return new WikiError( "Unknown XML-RPC error" ); |
| 186 | + throw new MWException( "Unknown XML-RPC error" ); |
187 | 187 | } elseif( $result->faultCode() ) { |
188 | | - return new WikiError( $result->faultCode() . ': ' . $result->faultString() ); |
| 188 | + throw new MWException( $result->faultCode() . ': ' . $result->faultString() ); |
189 | 189 | } else { |
190 | 190 | $value = $result->value(); |
191 | 191 | return $value->getval(); |
Index: trunk/extensions/MWSearch/luceneUpdate.php |
— | — | @@ -12,31 +12,56 @@ |
13 | 13 | exit( -1 ); |
14 | 14 | } |
15 | 15 | |
| 16 | +$ret = true; |
| 17 | + |
16 | 18 | switch( $args[0] ) { |
17 | 19 | case 'stop': |
18 | | - $ret = MWSearchUpdater::stop(); |
| 20 | + try { |
| 21 | + MWSearchUpdater::stop(); |
| 22 | + } catch ( MWException $e ) { |
| 23 | + $ret = $e; |
| 24 | + } |
19 | 25 | break; |
20 | 26 | case 'restart': |
21 | 27 | case 'flushall': |
22 | 28 | case 'flush': |
23 | | - $ret = MWSearchUpdater::flushAll(); |
| 29 | + try { |
| 30 | + MWSearchUpdater::flushAll(); |
| 31 | + } catch ( MWException $e ) { |
| 32 | + $ret = $e; |
| 33 | + } |
24 | 34 | break; |
25 | 35 | case 'start': |
26 | | - $ret = MWSearchUpdater::start(); |
| 36 | + try { |
| 37 | + MWSearchUpdater::start(); |
| 38 | + } catch ( MWException $e ) { |
| 39 | + $ret = $e; |
| 40 | + } |
27 | 41 | break; |
28 | 42 | //case 'flush': |
29 | 43 | // global $wgDBname; |
30 | | -// $ret = MWSearchUpdater::flush( $wgDBname ); |
| 44 | +// try { |
| 45 | +// MWSearchUpdater::flush( $wgDBname ); |
| 46 | +// } catch ( MWException $e ) { |
| 47 | +// $ret = $e; |
| 48 | +// } |
31 | 49 | // break; |
32 | 50 | case 'status': |
33 | 51 | // no-op |
34 | | - $ret = true; |
35 | 52 | break; |
36 | 53 | case 'quit': |
37 | | - $ret = MWSearchUpdater::quit(); |
| 54 | + try { |
| 55 | + MWSearchUpdater::quit(); |
| 56 | + } catch ( MWException $e ) { |
| 57 | + $ret = $e; |
| 58 | + } |
38 | 59 | break; |
39 | 60 | case 'optimize': |
40 | | - $ret = MWSearchUpdater::optimize(); |
| 61 | + try { |
| 62 | + MWSearchUpdater::optimize(); |
| 63 | + } catch ( MWException $e ) { |
| 64 | + $ret = $e; |
| 65 | + } |
41 | 66 | break; |
42 | 67 | case 'update': |
43 | 68 | $title = Title::newFromText( $args[1] ); |
— | — | @@ -44,11 +69,15 @@ |
45 | 70 | die( "Invalid title\n" ); |
46 | 71 | } |
47 | 72 | $rev = Revision::newFromTitle( $title ); |
48 | | - if( $rev ) { |
49 | | - $text = $rev->getText(); |
50 | | - $ret = MWSearchUpdater::updatePage( $wgDBname, $title, $text ); |
51 | | - } else { |
52 | | - $ret = MWSearchUpdater::deletePage( $wgDBname, $title ); |
| 73 | + try { |
| 74 | + if( $rev ) { |
| 75 | + $text = $rev->getText(); |
| 76 | + $ret = MWSearchUpdater::updatePage( $wgDBname, $title, $text ); |
| 77 | + } else { |
| 78 | + $ret = MWSearchUpdater::deletePage( $wgDBname, $title ); |
| 79 | + } |
| 80 | + } catch ( MWException $e ) { |
| 81 | + $ret = $e; |
53 | 82 | } |
54 | 83 | break; |
55 | 84 | case 'rebuild': |
— | — | @@ -96,18 +125,18 @@ |
97 | 126 | exit( -1 ); |
98 | 127 | } |
99 | 128 | |
100 | | -if( WikiError::isError( $ret ) ) { |
| 129 | +if( $ret instanceof MWException ) { |
101 | 130 | echo $ret->getMessage() . "\n"; |
102 | 131 | exit( -1 ); |
103 | 132 | } |
104 | 133 | |
105 | | -$status = MWSearchUpdater::getStatus(); |
106 | | -if( WikiError::isError( $status ) ) { |
107 | | - echo $status->getMessage() . "\n"; |
108 | | - exit( -1 ); |
109 | | -} else { |
| 134 | +try { |
| 135 | + $status = MWSearchUpdater::getStatus(); |
110 | 136 | echo $status . "\n"; |
111 | 137 | exit( 0 ); |
| 138 | +} catch ( MWException $e ) { |
| 139 | + echo $e->getMessage() . "\n"; |
| 140 | + exit( -1 ); |
112 | 141 | } |
113 | 142 | |
114 | 143 | |
— | — | @@ -172,9 +201,10 @@ |
173 | 202 | $waittime = 10; |
174 | 203 | |
175 | 204 | while( true ) { |
176 | | - $status = MWSearchUpdater::getStatus(); |
177 | | - if( WikiError::isError( $status ) ) { |
178 | | - echo $status->getMessage() . "\n"; |
| 205 | + try { |
| 206 | + $status = MWSearchUpdater::getStatus(); |
| 207 | + } catch ( MWException $e ) { |
| 208 | + echo $e->getMessage() . "\n"; |
179 | 209 | sleep( $waittime ); |
180 | 210 | continue; |
181 | 211 | } |
— | — | @@ -251,11 +281,12 @@ |
252 | 282 | } |
253 | 283 | |
254 | 284 | $text = $rev->getText(); |
255 | | - $hit = MWSearchUpdater::updatePage( $wgDBname, $title, $text ); |
256 | | - |
257 | | - if( WikiError::isError( $hit ) ) { |
258 | | - echo "ERROR: " . $hit->getMessage() . "\n"; |
259 | | - $lastError = $hit; |
| 285 | + |
| 286 | + try { |
| 287 | + MWSearchUpdater::updatePage( $wgDBname, $title, $text ); |
| 288 | + } catch( MWException $e ) { |
| 289 | + echo "ERROR: " . $e->getMessage() . "\n"; |
| 290 | + $lastError = $e; |
260 | 291 | $errorCount++; |
261 | 292 | if( $errorCount > 20 ) { |
262 | 293 | echo "Lots of errors, giving up. :(\n"; |
— | — | @@ -307,10 +338,11 @@ |
308 | 339 | foreach ( $result as $row ) { |
309 | 340 | $this->progress(); |
310 | 341 | $title = Title::makeTitle( $row->log_namespace, $row->log_title ); |
311 | | - $hit = MWSearchUpdater::deletePage( $wgDBname, $title ); |
312 | | - if( WikiError::isError( $hit ) ) { |
313 | | - echo "ERROR: " . $hit->getMessage() . "\n"; |
314 | | - $lastError = $hit; |
| 342 | + try { |
| 343 | + MWSearchUpdater::deletePage( $wgDBname, $title ); |
| 344 | + } catch ( MWException $e ) { |
| 345 | + echo "ERROR: " . $e->getMessage() . "\n"; |
| 346 | + $lastError = $e; |
315 | 347 | } |
316 | 348 | } |
317 | 349 | |
— | — | @@ -363,10 +395,11 @@ |
364 | 396 | $rev = new Revision( $row ); |
365 | 397 | if( is_object( $rev ) ) { |
366 | 398 | $title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
367 | | - $hit = MWSearchUpdater::updatePage( $wgDBname, $title, $rev->getText() ); |
368 | | - if( WikiError::isError( $hit ) ) { |
369 | | - echo "ERROR: " . $hit->getMessage() . "\n"; |
370 | | - $lastError = $hit; |
| 399 | + try { |
| 400 | + MWSearchUpdater::updatePage( $wgDBname, $title, $rev->getText() ); |
| 401 | + } catch ( MWException $e ) { |
| 402 | + echo "ERROR: " . $e->getMessage() . "\n"; |
| 403 | + $lastError = $e; |
371 | 404 | } |
372 | 405 | } |
373 | 406 | } |