Smalyshev has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/334414 )

Change subject: Fixes for more robust dealing with content handlers.
......................................................................

Fixes for more robust dealing with content handlers.

Change-Id: I12a02da005f4b2bceaa850bd1f41a90ac4e1754a
---
M includes/search/SearchEngine.php
1 file changed, 15 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/14/334414/1

diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php
index 0bcb07a..525337b 100644
--- a/includes/search/SearchEngine.php
+++ b/includes/search/SearchEngine.php
@@ -705,9 +705,23 @@
         */
        public function getSearchIndexFields() {
                $models = ContentHandler::getContentModels();
+               Hooks::run( 'SearchIndexModels', [ &$models, $this ] );
                $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] ) ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I12a02da005f4b2bceaa850bd1f41a90ac4e1754a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Smalyshev <[email protected]>

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

Reply via email to