Merge "Remove SourceIndexField FLAG_SOURCE_DATA"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 1 Sep 2016 18:59:55 +0000 (18:59 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 1 Sep 2016 18:59:55 +0000 (18:59 +0000)
1  2 
includes/content/WikitextContentHandler.php

@@@ -35,7 -35,7 +35,7 @@@ class WikitextContentHandler extends Te
        }
  
        protected function getContentClass() {
 -              return 'WikitextContent';
 +              return WikitextContent::class;
        }
  
        /**
        }
  
        public function getFieldsForSearchIndex( SearchEngine $engine ) {
 -              $fields = [];
 -
 -              $fields['category'] =
 -                      $engine->makeSearchFieldMapping( 'category', SearchIndexField::INDEX_TYPE_TEXT );
 -              $fields['category']->setFlag( SearchIndexField::FLAG_CASEFOLD );
 -
 -              $fields['external_link'] =
 -                      $engine->makeSearchFieldMapping( 'external_link', SearchIndexField::INDEX_TYPE_KEYWORD );
 +              $fields = parent::getFieldsForSearchIndex( $engine );
  
                $fields['heading'] =
                        $engine->makeSearchFieldMapping( 'heading', SearchIndexField::INDEX_TYPE_TEXT );
                $fields['opening_text']->setFlag( SearchIndexField::FLAG_SCORING |
                                                  SearchIndexField::FLAG_NO_HIGHLIGHT );
  
 -              $fields['outgoing_link'] =
 -                      $engine->makeSearchFieldMapping( 'outgoing_link', SearchIndexField::INDEX_TYPE_KEYWORD );
 -
 -              $fields['template'] =
 -                      $engine->makeSearchFieldMapping( 'template', SearchIndexField::INDEX_TYPE_KEYWORD );
 -              $fields['template']->setFlag( SearchIndexField::FLAG_CASEFOLD );
 -
                // FIXME: this really belongs in separate file handler but files
                // do not have separate handler. Sadness.
                $fields['file_text'] =
                        $engine->makeSearchFieldMapping( 'file_text', SearchIndexField::INDEX_TYPE_TEXT );
  
-               $fields['defaultsort'] = $engine->makeSearchFieldMapping( 'defaultsort',
-                       SearchIndexField::INDEX_TYPE_TEXT );
-               $fields['defaultsort']->setFlag( SearchIndexField::FLAG_SOURCE_DATA );
                return $fields;
        }
  
        protected function getFileText( Title $title ) {
                $file = wfLocalFile( $title );
                if ( $file && $file->exists() ) {
 -                      return $file->getHandler()->getEntireText( $file );
 +                      $handler = $file->getHandler();
 +                      if ( !$handler ) {
 +                              return null;
 +                      }
 +                      return $handler->getEntireText( $file );
                }
  
                return null;
                $fields = parent::getDataForSearchIndex( $page, $parserOutput, $engine );
  
                $structure = new WikiTextStructure( $parserOutput );
 -              $fields['external_link'] = array_keys( $parserOutput->getExternalLinks() );
 -              $fields['category'] = $structure->categories();
                $fields['heading'] = $structure->headings();
 -              $fields['outgoing_link'] = $structure->outgoingLinks();
 -              $fields['template'] = $structure->templates();
                // text fields
                $fields['opening_text'] = $structure->getOpeningText();
                $fields['text'] = $structure->getMainText(); // overwrites one from ContentHandler