Anomie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/266262

Change subject: Use ParserOutput::getRawText() where available
......................................................................

Use ParserOutput::getRawText() where available

This is unlikely to be a cause of the cache corruption since this isn't
calling setText() on any wikitext ParserOutputs, but let's fix it just
in case.

Bug: T124356
Change-Id: Ic34c654af86385dede843009d89df6f442ddc915
---
M common/ScribuntoContent.php
1 file changed, 16 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Scribunto 
refs/changes/62/266262/1

diff --git a/common/ScribuntoContent.php b/common/ScribuntoContent.php
index 65deee7..67de1ef 100644
--- a/common/ScribuntoContent.php
+++ b/common/ScribuntoContent.php
@@ -91,7 +91,7 @@
                $engine->setTitle( $title );
                $status = $engine->validate( $text, $title->getPrefixedDBkey() 
);
                if ( !$status->isOK() ) {
-                       $output->setText( $output->getText() .
+                       $output->setText( self::getPOText( $output ) .
                                Html::rawElement( 'div', array( 'class' => 
'errorbox' ),
                                        $status->getHTML( 
'scribunto-error-short', 'scribunto-error-long' )
                                )
@@ -138,14 +138,14 @@
                                        if ( $wgUseSiteCss ) {
                                                $output->addModuleStyles( 
'ext.geshi.local' );
                                        }
-                                       $output->setText( $output->getText() . 
$code );
+                                       $output->setText( self::getPOText( 
$output ) . $code );
                                        return $output;
                                }
                        }
                }
 
                // No GeSHi, or GeSHi can't parse it, use plain <pre>
-               $output->setText( $output->getText() .
+               $output->setText( self::getPOText( $output ) .
                        "<pre class='mw-code mw-script' dir='ltr'>\n" .
                        htmlspecialchars( $text ) .
                        "\n</pre>\n"
@@ -155,6 +155,19 @@
        }
 
        /**
+        * Fetch the text from a ParserOutput
+        * @todo Once support for MW without ParserOutput::getRawText() is 
dropped,
+        *  inline this.
+        * @param ParserOutput $po
+        * @return string
+        */
+       private static function getPOText( ParserOutput $po ) {
+               return is_callable( array( $po, 'getRawText' ) )
+                       ? $po->getRawText()
+                       : $po->getText();
+       }
+
+       /**
         * Returns a Content object with pre-save transformations applied (or 
this
         * object if no transformations apply).
         *

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic34c654af86385dede843009d89df6f442ddc915
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Scribunto
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