diff --git a/MathLaTeXML.php b/MathLaTeXML.php index 1bdd70c..f18a9d3 100644 --- a/MathLaTeXML.php +++ b/MathLaTeXML.php @@ -192,7 +192,7 @@ class MathLaTeXML extends MathRenderer { /** * Picks a LaTeXML daemon. - * If more than one demon are availible one is chosen from the + * If more than one daemon are available one is chosen from the * $wgMathLaTeXMLUrl array. * @return string */ @@ -252,7 +252,7 @@ class MathLaTeXML extends MathRenderer { // mess up the browser output. $this->lastError = $this->getError( 'math_latexml_invalidxml', $host ); wfDebugLog( "Math", "\nLaTeXML InvalidMathML:" - . var_export( array( 'post' => $post, 'host' => $host + . var_export( array( 'post' => $post, 'host' => $host , 'result' => $result ), true ) . "\n\n" ); wfProfileOut( __METHOD__ ); return false; @@ -261,7 +261,7 @@ class MathLaTeXML extends MathRenderer { $this->lastError = $this->getError( 'math_latexml_invalidjson', $host ); wfDebugLog( "Math", "\nLaTeXML InvalidJSON:" . var_export( array( 'post' => $post, 'host' => $host - , 'res' => $res ), true ) . "\n\n" ); + , 'res' => $res ), true ) . "\n\n" ); wfProfileOut( __METHOD__ ); return false; } @@ -347,4 +347,8 @@ class MathLaTeXML extends MathRenderer { return Xml::tags( 'span', $attribs, $mml ); } + protected function getMathTableName() { + return 'mathlatexml'; + } } + diff --git a/MathRenderer.php b/MathRenderer.php index 088c351..27d6e6d 100644 --- a/MathRenderer.php +++ b/MathRenderer.php @@ -182,8 +182,8 @@ abstract class MathRenderer { wfDebugLog( 'Math', $msg ); // If we can not check if mathml output is valid, we skip the test and assume that it is valid. $this->recall = true; - wfProfileOut( __METHOD__ ); - return true; + wfProfileOut( __METHOD__ ); + return true; } elseif ( StringUtils::isUtf8( $this->mathml ) ) { $this->recall = true; wfProfileOut( __METHOD__ ); @@ -191,7 +191,7 @@ abstract class MathRenderer { } } - # Missing from the database and/or the render cache + # Missing from the database and/or the render cache $this->recall = false; wfProfileOut( __METHOD__ ); return false; @@ -234,9 +234,9 @@ abstract class MathRenderer { wfDebugLog( "Math", 'store entry for $' . $this->tex . '$ in database (hash:' . bin2hex( $this->hash ) . ")\n" ); $outArray = $this->dbOutArray(); $dbw->onTransactionIdle( - function() use( $dbw, $outArray ) { - $dbw->replace( 'math', array( 'math_inputhash' ), $outArray, __METHOD__ ); - } ); + function() use( $dbw, $outArray ) { + $dbw->replace( 'math', array( 'math_inputhash' ), $outArray, __METHOD__ ); + } ); } } @@ -496,5 +496,12 @@ abstract class MathRenderer { public function getUserInputTex() { return $this->userInputTex; } -} + + protected abstract function getMathTableName(); + + public function getModeStr() { + $names = MathHooks::getMathNames(); + return $names[ $this->getMode() ]; + } +} diff --git a/MathSource.php b/MathSource.php index 8eabaef..6b395e5 100644 --- a/MathSource.php +++ b/MathSource.php @@ -46,4 +46,7 @@ class MathSource extends MathRenderer { ); } + protected function getMathTableName() { + throw new MWException ( 'in math source mode no database caching should happen'); + } } diff --git a/MathTexvc.php b/MathTexvc.php index 37e4b70..1641a40 100644 --- a/MathTexvc.php +++ b/MathTexvc.php @@ -360,4 +360,8 @@ class MathTexvc extends MathRenderer { return false; } + protected function getMathTableName() { + return 'math'; + } + } diff --git a/tests/MathRendererTest.php b/tests/MathRendererTest.php index 9ee43f1..8033233 100644 --- a/tests/MathRendererTest.php +++ b/tests/MathRendererTest.php @@ -26,7 +26,7 @@ class MathRendererTest extends MediaWikiTestCase { */ public function testWriteCacheSkip() { $renderer = $this->getMockBuilder( 'MathRenderer' ) - ->setMethods( array( 'writeToDatabase' , 'render' ) ) + ->setMethods( array( 'writeToDatabase' , 'render', 'getMathTableName' ) ) ->disableOriginalConstructor() ->getMock(); $renderer->expects( $this->never() ) @@ -40,7 +40,7 @@ class MathRendererTest extends MediaWikiTestCase { */ public function testWriteCache() { $renderer = $this->getMockBuilder( 'MathRenderer' ) - ->setMethods( array( 'writeToDatabase' , 'render' ) ) + ->setMethods( array( 'writeToDatabase' , 'render', 'getMathTableName' ) ) ->disableOriginalConstructor() ->getMock(); $renderer->expects( $this->never() ) @@ -54,7 +54,7 @@ class MathRendererTest extends MediaWikiTestCase { */ public function testChangeHash() { $renderer = $this->getMockBuilder( 'MathRenderer' ) - ->setMethods( array( 'render' ) ) + ->setMethods( array( 'render', 'getMathTableName' ) ) ->disableOriginalConstructor() ->getMock(); $this->assertEquals( @@ -71,7 +71,7 @@ class MathRendererTest extends MediaWikiTestCase { public function testSetPurge() { $renderer = $this->getMockBuilder( 'MathRenderer' ) - ->setMethods( array( 'render' ) ) + ->setMethods( array( 'render', 'getMathTableName' ) ) ->disableOriginalConstructor() ->getMock(); $renderer->setPurge();