diff --git a/Math.php b/Math.php index 266795e8d..79c021b1d 100644 --- a/Math.php +++ b/Math.php @@ -205,9 +205,6 @@ define( 'MW_MATH_CHECK_NEW' , 2 ); */ $wgMathDisableTexFilter = MW_MATH_CHECK_NEW; -/** Stores debug information in the database and provides more detailed debug output */ -$wgMathDebug = false; - /** @var boolean $wgMathEnableExperimentalInputFormats enables experimental MathML and AsciiMath input format support */ $wgMathEnableExperimentalInputFormats = false; ////////// end of config settings. diff --git a/MathLaTeXML.php b/MathLaTeXML.php index 727e04e17..18cb5953b 100644 --- a/MathLaTeXML.php +++ b/MathLaTeXML.php @@ -95,8 +95,6 @@ class MathLaTeXML extends MathMathML { * @return boolean */ protected function doRender() { - global $wgMathDebug; - if ( trim( $this->getTex() ) === '' ) { LoggerFactory::getInstance( 'Math' )->warning( 'Rendering was requested, but no TeX string is specified.' ); @@ -118,10 +116,9 @@ class MathLaTeXML extends MathMathML { if ( $jsonResult && json_last_error() === JSON_ERROR_NONE ) { if ( $this->isValidMathML( $jsonResult->result ) ) { $this->setMathml( $jsonResult->result ); - if ( $wgMathDebug ) { - $this->setLog( $jsonResult->log ); - $this->setStatusCode( $jsonResult->status_code ); - } + Hooks::run( 'MathRenderingResultRetrieved', + array( &$renderer, + &$jsonResult ) );// Enables debugging of server results return true; } else { // Do not print bad mathml. It's probably too verbose and might diff --git a/MathMathML.php b/MathMathML.php index cc23f1b23..948765129 100644 --- a/MathMathML.php +++ b/MathMathML.php @@ -195,6 +195,7 @@ class MathMathML extends MathRenderer { protected function pickHost() { if ( is_array( $this->hosts ) ) { $host = array_rand( $this->hosts ); + $this->hosts = $host; // Use the same host for this class instance } else { $host = $this->hosts; } @@ -463,7 +464,6 @@ class MathMathML extends MathRenderer { * @return bool */ private function processJsonResult( $jsonResult, $host ) { - global $wgMathDebug; if ( $this->getMode() == MW_MATH_LATEXML || $this->inputType == 'pmml' || $this->isValidMathML( $jsonResult->mml ) ) { @@ -479,12 +479,12 @@ class MathMathML extends MathRenderer { LoggerFactory::getInstance( 'Math' )->error( '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 ); } + Hooks::run( 'MathRenderingResultRetrieved', + array( &$renderer, + &$jsonResult ) );// Enables debugging of server results return true; } else { $this->lastError = $this->getError( 'math_unknown_error', $host ); diff --git a/MathRenderer.php b/MathRenderer.php index 6cebb36e1..396b9c7ad 100644 --- a/MathRenderer.php +++ b/MathRenderer.php @@ -13,8 +13,7 @@ use MediaWiki\Logger\LoggerFactory; * Abstract base class with static methods for rendering the tags using * different technologies. These static methods create a new instance of the * extending classes and render the math tags based on the mode setting of the user. - * Furthermore this class handles the caching of the rendered output and provides - * debug information, if run in mathdebug mode. + * Furthermore this class handles the caching of the rendered output. * * @author Tomasz Wegrzanowski * @author Brion Vibber @@ -39,15 +38,6 @@ abstract class MathRenderer { /** @var string a userdefined identifier to link to the equation. */ protected $id = ''; - // DEBUG VARIABLES - // Available, if Math extension runs in debug mode ($wgMathDebug = true) only. - /** @var int LaTeXML return code (will be available in future Mathoid versions as well) */ - protected $statusCode = 0; - /** @var timestamp of the last modification of the database entry */ - protected $timestamp; - /** @var log messages generated during conversion of mathematical content */ - protected $log = ''; - // STATE OF THE CLASS INSTANCE /** @var boolean has variable tex been security-checked */ protected $texSecure = false; @@ -325,7 +315,6 @@ abstract class MathRenderer { * @param DatabaseBase $dbw */ public function writeToDatabase( $dbw = null ) { - global $wgMathDebug; # Now save it back to the DB: if ( !wfReadOnly() ) { $dbw = $dbw ?: wfGetDB( DB_MASTER ); @@ -347,18 +336,16 @@ abstract class MathRenderer { } ); } else { $dbw->onTransactionIdle( function () use ( - $dbw, $outArray, $wgMathDebug, $method, $mathTableName + $dbw, $outArray, $method, $mathTableName ) { $dbw->insert( $mathTableName, $outArray, $method, array( 'IGNORE' ) ); - if ( $wgMathDebug ) { - LoggerFactory::getInstance( 'Math' )->debug( - 'Row inserted after db transaction was idle ' . - var_export( $outArray, true ) . " to database" ); - if ( $dbw->affectedRows() == 0 ) { - // That's the price for the delayed update. - LoggerFactory::getInstance( 'Math' )->warning( - 'Entry could not be written. Might be changed in between.' ); - } + LoggerFactory::getInstance( 'Math' )->debug( + 'Row inserted after db transaction was idle ' . + var_export( $outArray, true ) . " to database" ); + if ( $dbw->affectedRows() == 0 ) { + // That's the price for the delayed update. + LoggerFactory::getInstance( 'Math' )->warning( + 'Entry could not be written. Might be changed in between.' ); } } ); } @@ -420,14 +407,6 @@ abstract class MathRenderer { return $this->tex; } - /** - * gets the timestamp, of the last rendering of that equation - * @return int - */ - public function getTimestamp() { - return $this->timestamp; - } - /** * gets the rendering mode MW_MATH_* * @@ -549,13 +528,6 @@ abstract class MathRenderer { return $this->lastError; } - /** - * @return string - */ - public function getLog() { - return $this->log; - } - /** * * @param (MW_MATHSTYLE_INLINE_DISPLAYSTYLE|MW_MATHSTYLE_DISPLAY|MW_MATHSTYLE_INLINE) $mathStyle @@ -574,28 +546,7 @@ abstract class MathRenderer { public function getMathStyle() { return $this->mathStyle; } - /** - * @param string $log - */ - public function setLog( $log ) { - $this->changed = true; - $this->log = $log; - } - /** - * @return int - */ - public function getStatusCode() { - return $this->statusCode; - } - - /** - * @param unknown_type $statusCode - */ - public function setStatusCode( $statusCode ) { - $this->changed = true; - $this->statusCode = $statusCode; - } /** * Get if the input tex was marked as secure * @return boolean diff --git a/SpecialMathShowImage.php b/SpecialMathShowImage.php index 154e40d20..bffd4d2aa 100644 --- a/SpecialMathShowImage.php +++ b/SpecialMathShowImage.php @@ -119,11 +119,11 @@ class SpecialMathShowImage extends SpecialPage { * @return xml svg image with the error message */ private function printSvgError( $msg ) { - global $wgMathDebug; + global $wgDebugComments; $result = '' . '' . htmlspecialchars( $msg ) . ''; - if ( $wgMathDebug ) { + if ( $wgDebugComments ) { $result .= ''; } return $result; diff --git a/tests/MathDatabaseTest.php b/tests/MathDatabaseTest.php index fcd946cad..b4e468589 100644 --- a/tests/MathDatabaseTest.php +++ b/tests/MathDatabaseTest.php @@ -74,7 +74,7 @@ class MathDatabaseTest extends MediaWikiTestCase { /** - * Checks the creation of the math table without debugging enabled. + * Checks the creation of the math table. * @covers MathHooks::onLoadExtensionSchemaUpdates */ public function testCreateTable() { diff --git a/tests/MathLaTeXMLDatabaseTest.php b/tests/MathLaTeXMLDatabaseTest.php index 4f8e21bdc..fc7d2e03c 100644 --- a/tests/MathLaTeXMLDatabaseTest.php +++ b/tests/MathLaTeXMLDatabaseTest.php @@ -73,7 +73,7 @@ class MathLaTeXMLDatabaseTest extends MediaWikiTestCase { } /** - * Checks the creation of the math table without debugging enabled. + * Checks the creation of the math table. * @covers MathHooks::onLoadExtensionSchemaUpdates */ public function testCreateTable() {