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

Change subject: Set the ParserOptions::setCurrentRevisionCallback() $isSafe flag
......................................................................

Set the ParserOptions::setCurrentRevisionCallback() $isSafe flag

Needed so previews of edits to embedded stylesheets loaded from wiki
pages will work properly.

Useless but harmless without Ibc3fc372.

Bug: T160563
Change-Id: I84a3d9b8b9cec4a084498ca3e15d40a37ccb5a0f
---
M SpecialTemplateSandbox.php
M TemplateSandbox.hooks.php
M TemplateSandboxLogic.php
3 files changed, 7 insertions(+), 5 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TemplateSandbox 
refs/changes/43/347443/1

diff --git a/SpecialTemplateSandbox.php b/SpecialTemplateSandbox.php
index f26c040..e206129 100644
--- a/SpecialTemplateSandbox.php
+++ b/SpecialTemplateSandbox.php
@@ -202,7 +202,7 @@
                $popts->setIsPreview( true );
                $popts->setIsSectionPreview( false );
                $logic = new TemplateSandboxLogic( $this->prefixes, null, null 
);
-               $reset = $logic->setupForParse( $popts );
+               $reset = $logic->setupForParse( $popts, true );
                $this->title = $title;
                $this->output = $content->getParserOutput( $title, 
$rev->getId(), $popts );
 
diff --git a/TemplateSandbox.hooks.php b/TemplateSandbox.hooks.php
index 3d4c78d..dc4e1c6 100644
--- a/TemplateSandbox.hooks.php
+++ b/TemplateSandbox.hooks.php
@@ -137,7 +137,7 @@
                        $popts->setIsPreview( true );
                        $popts->setIsSectionPreview( false );
                        $logic = new TemplateSandboxLogic( [], $templatetitle, 
$content );
-                       $reset = $logic->setupForParse( $popts );
+                       $reset = $logic->setupForParse( $popts, 
$output->userCanPreview() );
                        $popts->enableLimitReport();
 
                        $rev = call_user_func_array( 
$popts->getCurrentRevisionCallback(), [ $title ] );
@@ -434,7 +434,7 @@
 
                if ( $prefixes || $templatetitle ) {
                        $logic = new TemplateSandboxLogic( $prefixes, 
$templatetitle, $content );
-                       $reset = $logic->setupForParse( $options );
+                       $reset = $logic->setupForParse( $options, true );
                        $suppressCache = true;
 
                        $wgHooks['ApiParseOutputPageForHeadHtml'][] = function 
( $module, $output )
diff --git a/TemplateSandboxLogic.php b/TemplateSandboxLogic.php
index 078dba9..baf7be6 100644
--- a/TemplateSandboxLogic.php
+++ b/TemplateSandboxLogic.php
@@ -33,9 +33,10 @@
        /**
         * Set up a ParserOptions for TemplateSandbox operation.
         * @param ParserOptions $popt
+        * @param bool $isSafe Whether it's safe to preview
         * @return ScopedCallback to uninstall
         */
-       public function setupForParse( ParserOptions $popt ) {
+       public function setupForParse( ParserOptions $popt, $isSafe ) {
                global $wgHooks;
 
                $id = 'TemplateSandbox.' . ++self::$counter;
@@ -87,7 +88,8 @@
                                        }
                                }
                                return call_user_func( 
$oldCurrentRevisionCallback, $title, $parser );
-                       }
+                       },
+                       $isSafe
                );
 
                LinkCache::singleton()->clear();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I84a3d9b8b9cec4a084498ca3e15d40a37ccb5a0f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TemplateSandbox
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to