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

Change subject: Parser on skins other than DefaultSkins
......................................................................

Parser on skins other than DefaultSkins

the last piece of the puzzle...

Someone more familiar with this code should feel free to fold this
into Legoktm's patch in a sane way...

Bug: T170880
Change-Id: I173b060765ebf67d009bdfb65cf60d7eb13bd4f5
---
M includes/parser/ParserOutput.php
M tests/parser/ParserTestRunner.php
2 files changed, 20 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/88/366988/1

diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php
index 10ac192..bad1614 100644
--- a/includes/parser/ParserOutput.php
+++ b/includes/parser/ParserOutput.php
@@ -23,6 +23,11 @@
  */
 class ParserOutput extends CacheTime {
        /**
+        * @var Skin $skin
+        */
+       protected $skin;
+
+       /**
         * @var string $mText The output text
         */
        public $mText;
@@ -249,13 +254,21 @@
                return $this->mText;
        }
 
+       /**
+        * set the skin associated with the parse
+        * @param Skin $skin
+        */
+       public function setSkin( Skin $skin ) {
+               $this->skin = $skin;
+       }
+
        public function getText() {
                $text = $this->mText;
                if ( $this->mEditSectionTokens ) {
                        $text = preg_replace_callback(
                                ParserOutput::EDITSECTION_REGEX,
                                function ( $m ) {
-                                       global $wgOut, $wgLang;
+                                       global $wgLang;
                                        $editsectionPage = Title::newFromText( 
htmlspecialchars_decode( $m[1] ) );
                                        $editsectionSection = 
htmlspecialchars_decode( $m[2] );
                                        $editsectionContent = isset( $m[4] ) ? 
$m[3] : null;
@@ -264,7 +277,11 @@
                                                throw new MWException( "Bad 
parser output text." );
                                        }
 
-                                       $skin = $wgOut->getSkin();
+                                       $skin = $this->skin;
+                                       if ( !$skin ) {
+                                               global $wgOut;
+                                               $wgOut->getSkin();
+                                       }
                                        return call_user_func_array(
                                                [ $skin, 'doEditSectionLink' ],
                                                [ $editsectionPage, 
$editsectionSection,
diff --git a/tests/parser/ParserTestRunner.php 
b/tests/parser/ParserTestRunner.php
index b225a49..d68b7ad 100644
--- a/tests/parser/ParserTestRunner.php
+++ b/tests/parser/ParserTestRunner.php
@@ -823,6 +823,7 @@
                $local = isset( $opts['local'] );
                $preprocessor = isset( $opts['preprocessor'] ) ? 
$opts['preprocessor'] : null;
                $parser = $this->getParser( $preprocessor );
+               $parser->setSkin( new DefaultSkin() );
                $title = Title::newFromText( $titleText );
 
                if ( isset( $opts['pst'] ) ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I173b060765ebf67d009bdfb65cf60d7eb13bd4f5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to