jenkins-bot has submitted this change and it was merged.

Change subject: LaTeXML: prevent automatic rerendering of SVG
......................................................................


LaTeXML: prevent automatic rerendering of SVG

MathMathML::renderingRequired called the getSvg
function in MathLaTeXML that caused an automatic
rerendering of the SVG image if it was not cached.
That this rendering is triggered from the function
renderingRequired is contra intutive and should be
avoided.

Change-Id: Ifa14f50193a05b3058624a18974c56897fcec09e
---
M MathLaTeXML.php
M MathMathML.php
M MathRenderer.php
3 files changed, 23 insertions(+), 11 deletions(-)

Approvals:
  Hoo man: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/MathLaTeXML.php b/MathLaTeXML.php
index 4915058..8df9251 100644
--- a/MathLaTeXML.php
+++ b/MathLaTeXML.php
@@ -178,7 +178,7 @@
         * No cache is used.
         * @return boolean
         */
-       public function calulateSvg() {
+       public function calculateSvg() {
                $renderer = new MathMathML( $this->getTex() );
                $renderer->setMathml( $this->getMathml() );
                $renderer->setMode( MW_MATH_LATEXML );
@@ -192,16 +192,22 @@
                return $res;
        }
 
+
        /**
         * Gets the SVG image
-        * Lazy evaluation: If no SVG image exists it's generated on the fly
+        *
+        * @param string $render if set to 'render' (default) and no SVG image 
exists, the function
+        *                       tries to generate it on the fly.
+        *                       Otherwise, if set to 'cached', and there is no 
SVG in the database
+        *                       cache, an empty string is returned.
+        *
         * @return string XML-Document of the rendered SVG
         */
-       public function getSvg() {
-               if ( $this->isPurge() || $this->svg == '' ) {
-                       $this->calulateSvg();
+       public function getSvg( $render = 'render' ) {
+               if ( $render == 'render' && ( $this->isPurge() || $this->svg == 
'' ) ) {
+                       $this->calculateSvg();
                }
-               return $this->svg;
+               return parent::getSvg( $render );
        }
 
        protected function getMathTableName() {
diff --git a/MathMathML.php b/MathMathML.php
index 03c648c..b42e7d8 100644
--- a/MathMathML.php
+++ b/MathMathML.php
@@ -107,7 +107,7 @@
                        if ( $dbres ) {
                                if ( $this->isValidMathML( $this->getMathml() ) 
) {
                                        wfDebugLog( 'Math', 'Valid MathML entry 
found in database.' );
-                                       if ( $this->getSvg() ) {
+                                       if ( $this->getSvg( 'cached' ) ) {
                                                wfDebugLog( 'Math', 
'SVG-fallback found in database.' );
                                                return false;
                                        } else {
@@ -214,8 +214,8 @@
                                // default preserve the (broken) layout as it 
was
                                $out = 'type=inline-TeX&q=' .rawurlencode( 
'{\\displaystyle ' . $input . '}' );
                        } else {
-                $out = 'type=tex&q=' . rawurlencode( $input );
-            }
+                               $out = 'type=tex&q=' . rawurlencode( $input );
+                       }
                }
                wfDebugLog( 'Math', 'Get post data: ' . $out );
                return $out;
diff --git a/MathRenderer.php b/MathRenderer.php
index 7139da0..7e69eb1 100644
--- a/MathRenderer.php
+++ b/MathRenderer.php
@@ -671,10 +671,16 @@
        }
 
        /**
+        * Gets the SVG image
         *
-        * @return type
+        * @param string $render if set to 'render' (default) and no SVG image 
exists, the function
+        *                       tries to generate it on the fly.
+        *                       Otherwise, if set to 'cached', and there is no 
SVG in the database
+        *                       cache, an empty string is returned.
+        *
+        * @return string XML-Document of the rendered SVG
         */
-       public function getSvg() {
+       public function getSvg( $render = 'render' ) {
                // Spaces will prevent the image from being displayed correctly 
in the browser
                return trim( $this->svg );
        }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifa14f50193a05b3058624a18974c56897fcec09e
Gerrit-PatchSet: 18
Gerrit-Project: mediawiki/extensions/Math
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Hcohl <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Physikerwelt <[email protected]>
Gerrit-Reviewer: Rastus Vernon <[email protected]>
Gerrit-Reviewer: TheDJ <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to