mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-28 01:10:09 +00:00
Merge "Add separate database table for LaTeXML (step 3)"
This commit is contained in:
commit
423d80ef35
|
@ -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';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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() ];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
protected function getMathTableName() {
|
||||
return 'math';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue