Physikerwelt has uploaded a new change for review.

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

Change subject: Ignore missing SVG attribute
......................................................................

Ignore missing SVG attribute

In some cases the SVG property of the mathoid JSON result
seems to be empty.
In that case we ignore the SVG rendering.

Bug: T87379
Change-Id: I98398ec59e1d0205ee32cca137ad29dbc9dddec9
---
M MathMathML.php
1 file changed, 36 insertions(+), 22 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Math 
refs/changes/87/186587/1

diff --git a/MathMathML.php b/MathMathML.php
index b42e7d8..42e752c 100644
--- a/MathMathML.php
+++ b/MathMathML.php
@@ -226,7 +226,6 @@
         * @return boolean
         */
        protected function doRender() {
-               global  $wgMathDebug;
                if ( $this->getTex() === '' ) {
                        wfDebugLog( 'Math', 'Rendering was requested, but no 
TeX string is specified.' );
                        $this->lastError = $this->getError( 'math_empty_tex' );
@@ -241,27 +240,7 @@
                        $jsonResult = json_decode( $res );
                        if ( $jsonResult && json_last_error() === 
JSON_ERROR_NONE ) {
                                if ( $jsonResult->success ) {
-                                       if ( $this->getMode() == 
MW_MATH_LATEXML ||
-                                                       $this->inputType == 
'pmml' ||
-                                                       $this->isValidMathML( 
$jsonResult->mml ) ) {
-                                               $xmlObject = new XmlTypeCheck( 
$jsonResult->svg, null, false );
-                                               if ( ! $xmlObject->wellFormed ) 
{
-                                                       $this->lastError = 
$this->getError( 'math_invalidxml', $host );
-                                                       return false;
-                                               } else {
-                                                       $this->setSvg( 
$jsonResult->svg );
-                                               }
-                                               if ( $wgMathDebug ) {
-                                                       $this->setLog( 
$jsonResult->log );
-                                               }
-                                               if ( $this->getMode() != 
MW_MATH_LATEXML && $this->inputType != 'pmml') {
-                                                       $this->setMathml( 
$jsonResult->mml );
-                                               }
-                                               return true;
-                                       } else {
-                                               $this->lastError = 
$this->getError( 'math_unknown_error', $host );
-                                               return false;
-                                       }
+                                       return $this->processJsonResult( 
$jsonResult, $host );
                                } else {
                                        if ( property_exists( $jsonResult, 
'log' ) ) {
                                                $log = $jsonResult->log;
@@ -469,4 +448,39 @@
                parent::initializeFromDatabaseRow( $rpage );
 
        }
+
+       /**
+        * @param $jsonResult
+        * @param $host
+        *
+        * @return bool
+        */
+       private function processJsonResult( $jsonResult, $host ) {
+               global $wgMathDebug;
+               if ( $this->getMode() == MW_MATH_LATEXML || $this->inputType == 
'pmml' ||
+                        $this->isValidMathML( $jsonResult->mml )
+               ) {
+                       if ( isset( $jsonResult->svg ) ) {
+                               $xmlObject = new XmlTypeCheck( 
$jsonResult->svg, null, false );
+                               if ( !$xmlObject->wellFormed ) {
+                                       $this->lastError = $this->getError( 
'math_invalidxml', $host );
+                                       return false;
+                               } else {
+                                       $this->setSvg( $jsonResult->svg );
+                               }
+                       } else {
+                               wfDebugLog( 'Math', 'Missing SVG property in 
JSON result.' );
+                       }
+                       if ( $wgMathDebug ) {
+                               $this->setLog( $jsonResult->log );
+                       }
+                       if ( $this->getMode() != MW_MATH_LATEXML && 
$this->inputType != 'pmml' ) {
+                               $this->setMathml( $jsonResult->mml );
+                       }
+                       return true;
+               } else {
+                       $this->lastError = $this->getError( 
'math_unknown_error', $host );
+                       return false;
+               }
+       }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I98398ec59e1d0205ee32cca137ad29dbc9dddec9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Math
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <w...@physikerwelt.de>

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

Reply via email to