Merge "Standardise preview warning box when using ?action=edit"
[lhc/web/wiklou.git] / includes / content / WikitextContentHandler.php
index 9c26ae1..191c718 100644 (file)
@@ -23,6 +23,8 @@
  * @ingroup Content
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Content handler for wiki text pages.
  *
@@ -60,7 +62,7 @@ class WikitextContentHandler extends TextContentHandler {
                        }
                }
 
-               $mwRedir = MagicWord::get( 'redirect' );
+               $mwRedir = MediaWikiServices::getInstance()->getMagicWordFactory()->get( 'redirect' );
                $redirectText = $mwRedir->getSynonym( 0 ) .
                        ' [[' . $optionalColon . $destination->getFullText() . ']]';
 
@@ -160,4 +162,24 @@ class WikitextContentHandler extends TextContentHandler {
                return $fields;
        }
 
+       /**
+        * Returns the content's text as-is.
+        *
+        * @param Content $content
+        * @param string|null $format The serialization format to check
+        *
+        * @return mixed
+        */
+       public function serializeContent( Content $content, $format = null ) {
+               $this->checkFormat( $format );
+
+               // NOTE: MessageContent also uses CONTENT_MODEL_WIKITEXT, but it's not a TextContent!
+               // Perhaps MessageContent should use a separate ContentHandler instead.
+               if ( $content instanceof MessageContent ) {
+                       return $content->getMessage()->plain();
+               }
+
+               return parent::serializeContent( $content, $format );
+       }
+
 }