From 60ffe51c79577436326296a9aa76d66e5acfb200 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Thu, 26 Jan 2017 11:18:56 -0800 Subject: [PATCH] Fixes for more robust dealing with content handlers. Change-Id: I12a02da005f4b2bceaa850bd1f41a90ac4e1754a --- includes/search/SearchEngine.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index 0bcb07a5a6..87701cdcc2 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -706,8 +706,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] ) ) { -- 2.20.1