Merge "Fixes for more robust dealing with content handlers."
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 30 Jan 2017 16:06:25 +0000 (16:06 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 30 Jan 2017 16:06:25 +0000 (16:06 +0000)
includes/search/SearchEngine.php

index 206067f..9817b6c 100644 (file)
@@ -720,8 +720,21 @@ abstract class SearchEngine {
        public function getSearchIndexFields() {
                $models = ContentHandler::getContentModels();
                $fields = [];
+               $seenHandlers = new SplObjectStorage();
                foreach ( $models as $model ) {
-                       $handler = ContentHandler::getForModelID( $model );
+                       try {
+                               $handler = ContentHandler::getForModelID( $model );
+                       }
+                       catch ( MWUnknownContentModelException $e ) {
+                               // If we can find no handler, ignore it
+                               continue;
+                       }
+                       // Several models can have the same handler, so avoid processing it repeatedly
+                       if ( $seenHandlers->contains( $handler ) ) {
+                               // We already did this one
+                               continue;
+                       }
+                       $seenHandlers->attach( $handler );
                        $handlerFields = $handler->getFieldsForSearchIndex( $this );
                        foreach ( $handlerFields as $fieldName => $fieldData ) {
                                if ( empty( $fields[$fieldName] ) ) {