From: jenkins-bot Date: Mon, 30 Jan 2017 16:06:25 +0000 (+0000) Subject: Merge "Fixes for more robust dealing with content handlers." X-Git-Tag: 1.31.0-rc.0~4195 X-Git-Url: http://git.cyclocoop.org/%22.%24image2.%22?a=commitdiff_plain;h=0a2297c406a1bcf24a29f59a9596661e097ce665;hp=-c;p=lhc%2Fweb%2Fwiklou.git Merge "Fixes for more robust dealing with content handlers." --- 0a2297c406a1bcf24a29f59a9596661e097ce665 diff --combined includes/search/SearchEngine.php index 206067f0a7,87701cdcc2..9817b6cc99 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@@ -109,20 -109,6 +109,20 @@@ abstract class SearchEngine $this->features[$feature] = $data; } + /** + * Way to retrieve custom data set by setFeatureData + * or by the engine itself. + * @since 1.29 + * @param string $feature feature name + * @return mixed the feature value or null if unset + */ + public function getFeatureData( $feature ) { + if ( isset ( $this->features[$feature] ) ) { + return $this->features[$feature]; + } + return null; + } + /** * When overridden in derived class, performs database-specific conversions * on text to be used for searching or updating search index. @@@ -720,8 -706,21 +720,21 @@@ 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] ) ) {