From: Stanislav Malyshev Date: Thu, 26 Jan 2017 19:18:56 +0000 (-0800) Subject: Fixes for more robust dealing with content handlers. X-Git-Tag: 1.31.0-rc.0~4195^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22suivi_revisions%22%2C%22id_auteur=%24connecte%22%29%20.%20%22?a=commitdiff_plain;h=60ffe51c79577436326296a9aa76d66e5acfb200;p=lhc%2Fweb%2Fwiklou.git Fixes for more robust dealing with content handlers. Change-Id: I12a02da005f4b2bceaa850bd1f41a90ac4e1754a --- 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] ) ) {