From 897afa480b275da785d3b0148d058c9f792f849a Mon Sep 17 00:00:00 2001 From: physikerwelt Date: Mon, 30 Nov 2015 00:14:22 +0100 Subject: [PATCH] Use RestBase to check input tex rather than texvccheck * This will increase the performance of tex rendering for all rendering modes since no shell access is required anymore. Merge with caution. If the connection to restbase fails, rendering of new formulae will be completely disabled i.e. broken. Change-Id: I1982612e8c6a356e3dbdf447724ac82e5968cc77 --- MathRenderer.php | 2 +- tests/MathRendererTest.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/MathRenderer.php b/MathRenderer.php index 0a99a5e..1fe7ba7 100644 --- a/MathRenderer.php +++ b/MathRenderer.php @@ -572,7 +572,7 @@ abstract class MathRenderer { return true; } } - $checker = new MathInputCheckTexvc( $this->userInputTex ); + $checker = new MathInputCheckRestbase( $this->userInputTex ); if ( $checker->isValid() ) { $this->setTex( $checker->getValidTex() ); $this->texSecure = true; diff --git a/tests/MathRendererTest.php b/tests/MathRendererTest.php index 1ac899d..4ab6e68 100644 --- a/tests/MathRendererTest.php +++ b/tests/MathRendererTest.php @@ -8,6 +8,25 @@ class MathRendererTest extends MediaWikiTestCase { const SOME_TEX = "a+b"; const TEXVCCHECK_INPUT = '\forall \epsilon \exist \delta'; const TEXVCCHECK_OUTPUT = '\forall \epsilon \exists \delta '; // be aware of the s at exists + + protected static $hasRestbase; + + public static function setUpBeforeClass() { + $rbi = new MathRestbaseInterface(); + self::$hasRestbase = $rbi->checkBackend( true ); + } + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + protected function setUp() { + parent::setUp(); + if ( !self::$hasRestbase ) { + $this->markTestSkipped( "Can not connect to Restbase Math interface." ); + } + } + /** * Checks the tex and hash functions * @covers MathRenderer::getTex()