Update RELEASE-NOTES
[lhc/web/wiklou.git] / includes / content / JavaScriptContent.php
index 4bde738..4804758 100644 (file)
@@ -25,6 +25,8 @@
  * @author Daniel Kinzler
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Content for JavaScript pages.
  *
@@ -56,12 +58,12 @@ class JavaScriptContent extends TextContent {
         * @return JavaScriptContent
         */
        public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) {
-               global $wgParser;
                // @todo Make pre-save transformation optional for script pages
                // See T34858
 
-               $text = $this->getNativeData();
-               $pst = $wgParser->preSaveTransform( $text, $title, $user, $popts );
+               $text = $this->getText();
+               $pst = MediaWikiServices::getInstance()->getParser()
+                       ->preSaveTransform( $text, $title, $user, $popts );
 
                return new static( $pst );
        }
@@ -72,7 +74,7 @@ class JavaScriptContent extends TextContent {
        protected function getHtml() {
                $html = "";
                $html .= "<pre class=\"mw-code mw-js\" dir=\"ltr\">\n";
-               $html .= htmlspecialchars( $this->getNativeData() );
+               $html .= htmlspecialchars( $this->getText() );
                $html .= "\n</pre>\n";
 
                return $html;
@@ -101,12 +103,12 @@ class JavaScriptContent extends TextContent {
                        return $this->redirectTarget;
                }
                $this->redirectTarget = null;
-               $text = $this->getNativeData();
+               $text = $this->getText();
                if ( strpos( $text, '/* #REDIRECT */' ) === 0 ) {
                        // Extract the title from the url
                        preg_match( '/title=(.*?)\\\\u0026action=raw/', $text, $matches );
                        if ( isset( $matches[1] ) ) {
-                               $title = Title::newFromText( $matches[1] );
+                               $title = Title::newFromText( urldecode( $matches[1] ) );
                                if ( $title ) {
                                        // Have a title, check that the current content equals what
                                        // the redirect content should be