Add separate database table for LaTeXML (step 3)
Currently the PNG and the LaTeXML rendering mode use a common table in the database. If both rendering modes are allowed in a wiki simultaneously this causes problems, because the fields are continuously overwritten. This change adds the method getMathTableName that will allow renderers to access their specific table in the database. Change-Id: I8b11ffd0a39fadd7d3c8de1e94e74ff5f490430d
This commit is contained in:
parent
1de09cd270
commit
bf33d51320
|
@ -192,7 +192,7 @@ class MathLaTeXML extends MathRenderer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Picks a LaTeXML daemon.
|
* 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.
|
* $wgMathLaTeXMLUrl array.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -252,7 +252,7 @@ class MathLaTeXML extends MathRenderer {
|
||||||
// mess up the browser output.
|
// mess up the browser output.
|
||||||
$this->lastError = $this->getError( 'math_latexml_invalidxml', $host );
|
$this->lastError = $this->getError( 'math_latexml_invalidxml', $host );
|
||||||
wfDebugLog( "Math", "\nLaTeXML InvalidMathML:"
|
wfDebugLog( "Math", "\nLaTeXML InvalidMathML:"
|
||||||
. var_export( array( 'post' => $post, 'host' => $host
|
. var_export( array( 'post' => $post, 'host' => $host
|
||||||
, 'result' => $result ), true ) . "\n\n" );
|
, 'result' => $result ), true ) . "\n\n" );
|
||||||
wfProfileOut( __METHOD__ );
|
wfProfileOut( __METHOD__ );
|
||||||
return false;
|
return false;
|
||||||
|
@ -261,7 +261,7 @@ class MathLaTeXML extends MathRenderer {
|
||||||
$this->lastError = $this->getError( 'math_latexml_invalidjson', $host );
|
$this->lastError = $this->getError( 'math_latexml_invalidjson', $host );
|
||||||
wfDebugLog( "Math", "\nLaTeXML InvalidJSON:"
|
wfDebugLog( "Math", "\nLaTeXML InvalidJSON:"
|
||||||
. var_export( array( 'post' => $post, 'host' => $host
|
. var_export( array( 'post' => $post, 'host' => $host
|
||||||
, 'res' => $res ), true ) . "\n\n" );
|
, 'res' => $res ), true ) . "\n\n" );
|
||||||
wfProfileOut( __METHOD__ );
|
wfProfileOut( __METHOD__ );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -347,4 +347,8 @@ class MathLaTeXML extends MathRenderer {
|
||||||
return Xml::tags( 'span', $attribs, $mml );
|
return Xml::tags( 'span', $attribs, $mml );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getMathTableName() {
|
||||||
|
return 'mathlatexml';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -182,8 +182,8 @@ abstract class MathRenderer {
|
||||||
wfDebugLog( 'Math', $msg );
|
wfDebugLog( 'Math', $msg );
|
||||||
// If we can not check if mathml output is valid, we skip the test and assume that it is valid.
|
// If we can not check if mathml output is valid, we skip the test and assume that it is valid.
|
||||||
$this->recall = true;
|
$this->recall = true;
|
||||||
wfProfileOut( __METHOD__ );
|
wfProfileOut( __METHOD__ );
|
||||||
return true;
|
return true;
|
||||||
} elseif ( StringUtils::isUtf8( $this->mathml ) ) {
|
} elseif ( StringUtils::isUtf8( $this->mathml ) ) {
|
||||||
$this->recall = true;
|
$this->recall = true;
|
||||||
wfProfileOut( __METHOD__ );
|
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;
|
$this->recall = false;
|
||||||
wfProfileOut( __METHOD__ );
|
wfProfileOut( __METHOD__ );
|
||||||
return false;
|
return false;
|
||||||
|
@ -234,9 +234,9 @@ abstract class MathRenderer {
|
||||||
wfDebugLog( "Math", 'store entry for $' . $this->tex . '$ in database (hash:' . bin2hex( $this->hash ) . ")\n" );
|
wfDebugLog( "Math", 'store entry for $' . $this->tex . '$ in database (hash:' . bin2hex( $this->hash ) . ")\n" );
|
||||||
$outArray = $this->dbOutArray();
|
$outArray = $this->dbOutArray();
|
||||||
$dbw->onTransactionIdle(
|
$dbw->onTransactionIdle(
|
||||||
function() use( $dbw, $outArray ) {
|
function() use( $dbw, $outArray ) {
|
||||||
$dbw->replace( 'math', array( 'math_inputhash' ), $outArray, __METHOD__ );
|
$dbw->replace( 'math', array( 'math_inputhash' ), $outArray, __METHOD__ );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,5 +496,12 @@ abstract class MathRenderer {
|
||||||
public function getUserInputTex() {
|
public function getUserInputTex() {
|
||||||
return $this->userInputTex;
|
return $this->userInputTex;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
protected abstract function getMathTableName();
|
||||||
|
|
||||||
|
public function getModeStr() {
|
||||||
|
$names = MathHooks::getMathNames();
|
||||||
|
return $names[ $this->getMode() ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -46,4 +46,7 @@ class MathSource extends MathRenderer {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getMathTableName() {
|
||||||
|
throw new MWException ( 'in math source mode no database caching should happen');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -360,4 +360,8 @@ class MathTexvc extends MathRenderer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getMathTableName() {
|
||||||
|
return 'math';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ class MathRendererTest extends MediaWikiTestCase {
|
||||||
*/
|
*/
|
||||||
public function testWriteCacheSkip() {
|
public function testWriteCacheSkip() {
|
||||||
$renderer = $this->getMockBuilder( 'MathRenderer' )
|
$renderer = $this->getMockBuilder( 'MathRenderer' )
|
||||||
->setMethods( array( 'writeToDatabase' , 'render' ) )
|
->setMethods( array( 'writeToDatabase' , 'render', 'getMathTableName' ) )
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$renderer->expects( $this->never() )
|
$renderer->expects( $this->never() )
|
||||||
|
@ -40,7 +40,7 @@ class MathRendererTest extends MediaWikiTestCase {
|
||||||
*/
|
*/
|
||||||
public function testWriteCache() {
|
public function testWriteCache() {
|
||||||
$renderer = $this->getMockBuilder( 'MathRenderer' )
|
$renderer = $this->getMockBuilder( 'MathRenderer' )
|
||||||
->setMethods( array( 'writeToDatabase' , 'render' ) )
|
->setMethods( array( 'writeToDatabase' , 'render', 'getMathTableName' ) )
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$renderer->expects( $this->never() )
|
$renderer->expects( $this->never() )
|
||||||
|
@ -54,7 +54,7 @@ class MathRendererTest extends MediaWikiTestCase {
|
||||||
*/
|
*/
|
||||||
public function testChangeHash() {
|
public function testChangeHash() {
|
||||||
$renderer = $this->getMockBuilder( 'MathRenderer' )
|
$renderer = $this->getMockBuilder( 'MathRenderer' )
|
||||||
->setMethods( array( 'render' ) )
|
->setMethods( array( 'render', 'getMathTableName' ) )
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
|
@ -71,7 +71,7 @@ class MathRendererTest extends MediaWikiTestCase {
|
||||||
|
|
||||||
public function testSetPurge() {
|
public function testSetPurge() {
|
||||||
$renderer = $this->getMockBuilder( 'MathRenderer' )
|
$renderer = $this->getMockBuilder( 'MathRenderer' )
|
||||||
->setMethods( array( 'render' ) )
|
->setMethods( array( 'render', 'getMathTableName' ) )
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$renderer->setPurge();
|
$renderer->setPurge();
|
||||||
|
|
Loading…
Reference in New Issue