From db3026d5e123571e48a0839e54a262caeac4e878 Mon Sep 17 00:00:00 2001 From: physikerwelt Date: Thu, 28 Aug 2014 11:57:53 -0400 Subject: [PATCH] Error reporting for Mathoid Currently the error reporting in MathML mode is misleading. The old error message suggested that the MathML produced is not well formed. This change displays the actual error message occurred during the conversion process. Change-Id: I6a8201107f9280f0cba97509f19b97d8e248c99f --- MathMathML.php | 15 +++++++++------ i18n/en.json | 3 ++- i18n/qqq.json | 1 + 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/MathMathML.php b/MathMathML.php index 1dd8efc..82eea5e 100644 --- a/MathMathML.php +++ b/MathMathML.php @@ -263,12 +263,15 @@ class MathMathML extends MathRenderer { return false; } } else { - // Do not print bad mathml. It's probably too verbose and might - // mess up the browser output. - $this->lastError = $this->getError( 'math_invalidxml', $host ); - wfDebugLog( 'Math', "\nMathML InvalidMathML:" - . var_export( array( 'post' => $post, 'host' => $host - , 'result' => $res ), true ) . "\n\n" ); + if ( property_exists( $jsonResult, 'log' ) ) { + $log = $jsonResult->log; + } else { + $log = wfMessage( 'math_unknown_error' )->inContentLanguage()->escaped(); + } + $this->lastError = $this->getError( 'math_mathoid_error', $host, $log ); + wfDebugLog( 'Math', "Mathoid conversion error:" + . var_export( array( 'post' => $post, 'host' => $host + , 'result' => $res ), true ) . "\n\n" ); return false; } } else { diff --git a/i18n/en.json b/i18n/en.json index 5be1887..adf1f43 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -24,8 +24,9 @@ "math_output_error": "Cannot store math image on filesystem.", "math_timeout": "$1 timeout from \"$2\".", "math_invalidresponse": "$1: Invalid response (\"$3\") from server \"$2\":", - "math_invalidxml": "MathML is invalid XML.", + "math_invalidxml": "MathML or SVG is invalid XML.", "math_invalidjson": "$1 server response is invalid JSON.", + "math_mathoid_error": "Conversion error. Server (\"$1\") reported: \"$2\"", "math_xmlversion": "Warning: XML type check skipped! Check if your MediaWiki installation is version wmf/1.22wmf7 or newer.", "math-visualeditor-mwmathinspector-title": "Formula", "math-preference-mwmathinspector-description": "Add experimental support to VisualEditor for creating and editing of mathematical formulae for testing, ahead of general release. Please remember to always review your changes before saving when using experimental features.", diff --git a/i18n/qqq.json b/i18n/qqq.json index ed6f875..5caae30 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -36,6 +36,7 @@ "math_invalidxml": "Used as error message.\n\nThis message follows the message {{msg-mw|Math failure}}.", "math_invalidjson": "Used as error message.\n\nParameters:\n* $1 - rendering type (either LaTeXML or Mathoid)\n\nThis message follows the message {{msg-mw|Math failure}}.", "math_xmlversion": "Warning that XML checking of MathML requires wmf/1.22wmf7 or newer.", + "math_mathoid_error": "Used as error message.\n\nFollows the message {{msg-mw|Math failure}}.\n\nParameters:\n* $1 - hostname\n* $2 - error message retrieved from the server", "math-visualeditor-mwmathinspector-title": "Title for the inspector to edit formula blocks.\n{{Identical|Formula}}", "math-preference-mwmathinspector-description": "Used in [[Special:Preferences]].\n\nUsed as description for the checkbox to enable editing of mathematical formulae in VisualEditor.\n\nThe label for this checkbox is {{msg-mw|Math-preference-mwmathinspector-label}}.", "math-preference-mwmathinspector-discussion-link": "{{optional|Used on [[Special:Preferences]] as a link to a page where users can discuss this Beta Feature. Defaults to a page on MediaWiki.org.}}",