Merge "Defer calling ChronologyProtector::initLB() until connecting"
[lhc/web/wiklou.git] / includes / content / ContentHandler.php
index 5862bf1..bccb147 100644 (file)
@@ -361,7 +361,9 @@ abstract class ContentHandler {
        public static function getContentModels() {
                global $wgContentHandlers;
 
-               return array_keys( $wgContentHandlers );
+               $models = array_keys( $wgContentHandlers );
+               Hooks::run( 'GetContentModels', [ &$models ] );
+               return $models;
        }
 
        public static function getAllContentFormats() {
@@ -897,7 +899,7 @@ abstract class ContentHandler {
                        $onlyAuthor = $row->rev_user_text;
                        // Try to find a second contributor
                        foreach ( $res as $row ) {
-                               if ( $row->rev_user_text != $onlyAuthor ) { // Bug 22999
+                               if ( $row->rev_user_text != $onlyAuthor ) { // T24999
                                        $onlyAuthor = false;
                                        break;
                                }
@@ -1104,7 +1106,6 @@ abstract class ContentHandler {
                        'category',
                        SearchIndexField::INDEX_TYPE_TEXT
                );
-
                $fields['category']->setFlag( SearchIndexField::FLAG_CASEFOLD );
 
                $fields['external_link'] = $engine->makeSearchFieldMapping(
@@ -1121,9 +1122,13 @@ abstract class ContentHandler {
                        'template',
                        SearchIndexField::INDEX_TYPE_KEYWORD
                );
-
                $fields['template']->setFlag( SearchIndexField::FLAG_CASEFOLD );
 
+               $fields['content_model'] = $engine->makeSearchFieldMapping(
+                       'content_model',
+                       SearchIndexField::INDEX_TYPE_KEYWORD
+               );
+
                return $fields;
        }
 
@@ -1152,8 +1157,11 @@ abstract class ContentHandler {
         * @return array Map of name=>value for fields
         * @since 1.28
         */
-       public function getDataForSearchIndex( WikiPage $page, ParserOutput $output,
-                                              SearchEngine $engine ) {
+       public function getDataForSearchIndex(
+               WikiPage $page,
+               ParserOutput $output,
+               SearchEngine $engine
+       ) {
                $fieldData = [];
                $content = $page->getContent();
 
@@ -1170,6 +1178,7 @@ abstract class ContentHandler {
                        $fieldData['text'] = $text;
                        $fieldData['source_text'] = $text;
                        $fieldData['text_bytes'] = $content->getSize();
+                       $fieldData['content_model'] = $content->getModel();
                }
 
                Hooks::run( 'SearchDataForIndex', [ &$fieldData, $this, $page, $output, $engine ] );