Manybubbles has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/88138


Change subject: Wrap updateOneSearchIndexConfig in top level catch
......................................................................

Wrap updateOneSearchIndexConfig in top level catch

This should get us more information in the case of failures and prevent
the unsightly non-mediawiki exception complaint.

Change-Id: Ia396b99da33861d26a90f4cdea6283e298fa7e98
---
M maintenance/updateOneSearchIndexConfig.php
1 file changed, 31 insertions(+), 25 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch 
refs/changes/38/88138/1

diff --git a/maintenance/updateOneSearchIndexConfig.php 
b/maintenance/updateOneSearchIndexConfig.php
index a701d84..575cd67 100644
--- a/maintenance/updateOneSearchIndexConfig.php
+++ b/maintenance/updateOneSearchIndexConfig.php
@@ -81,33 +81,39 @@
        }
 
        public function execute() {
-               $this->indexType = $this->getOption( 'indexType' );
-               if ( $this->indexType !== 
CirrusSearchConnection::CONTENT_INDEX_TYPE &&
-                               $this->indexType !== 
CirrusSearchConnection::GENERAL_INDEX_TYPE ) {
-                       $this->error( 'indexType option must be ' . 
CirrusSearchConnection::CONTENT_INDEX_TYPE .
-                               ' or ' . 
CirrusSearchConnection::GENERAL_INDEX_TYPE, 1 );
-               }
-               $this->indent = $this->getOption( 'indent', '' );
-               if ( $this->getOption( 'forceOpen', false ) ) {
-                       $this->getIndex()->open();
-                       return;
-               }
-               if ( $this->getOption( 'forceReindex', false ) ) {
-                       $this->reindex();
-                       return;
-               }
-               $this->rebuild = $this->getOption( 'rebuild', false );
-               $this->closeOk = $this->getOption( 'closeOk', false );
-               $this->indexIdentifier = $this->pickIndexIdentifierFromOption( 
$this->getOption( 'indexIdentifier', 'current' ) );
-               $this->reindexAndRemoveOk = $this->getOption( 
'reindexAndRemoveOk', false );
+               try{
+                       $this->indexType = $this->getOption( 'indexType' );
+                       if ( $this->indexType !== 
CirrusSearchConnection::CONTENT_INDEX_TYPE &&
+                                       $this->indexType !== 
CirrusSearchConnection::GENERAL_INDEX_TYPE ) {
+                               $this->error( 'indexType option must be ' . 
CirrusSearchConnection::CONTENT_INDEX_TYPE .
+                                       ' or ' . 
CirrusSearchConnection::GENERAL_INDEX_TYPE, 1 );
+                       }
+                       $this->indent = $this->getOption( 'indent', '' );
+                       if ( $this->getOption( 'forceOpen', false ) ) {
+                               $this->getIndex()->open();
+                               return;
+                       }
+                       if ( $this->getOption( 'forceReindex', false ) ) {
+                               $this->reindex();
+                               return;
+                       }
+                       $this->rebuild = $this->getOption( 'rebuild', false );
+                       $this->closeOk = $this->getOption( 'closeOk', false );
+                       $this->indexIdentifier = 
$this->pickIndexIdentifierFromOption( $this->getOption( 'indexIdentifier', 
'current' ) );
+                       $this->reindexAndRemoveOk = $this->getOption( 
'reindexAndRemoveOk', false );
 
-               $this->validateIndex();
-               $this->validateAnalyzers();
-               $this->validateMapping();
-               $this->validateAlias();
+                       $this->validateIndex();
+                       $this->validateAnalyzers();
+                       $this->validateMapping();
+                       $this->validateAlias();
 
-               if ( $this->closed ) {
-                       $this->getIndex()->open();
+                       if ( $this->closed ) {
+                               $this->getIndex()->open();
+                       }
+               } catch ( \Elastica\Exception\ExceptionInterface $e ) {
+                       $message = $e->getMessage();
+                       $this->output( "Unexpected Elasticsearch failure.\n" );
+                       $this->error( "Elasticsearch failed at an unexpected 
place.  Here is Elasticsearch's error message: $message\n", 1 );
                }
                if ( $this->returnCode ) {
                        die( $this->returnCode );

-- 
To view, visit https://gerrit.wikimedia.org/r/88138
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia396b99da33861d26a90f4cdea6283e298fa7e98
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Manybubbles <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to