Physikerwelt has submitted this change and it was merged. Change subject: Select rendering engine for batch update script ......................................................................
Select rendering engine for batch update script Add option to select which renderer should be used to perform the Math Formulae update Change-Id: I074d3938c2898f4124f1b5ad11186863b0455172 --- M db/mathperformance.sql M maintenance/UpdateMath.php 2 files changed, 15 insertions(+), 9 deletions(-) Approvals: Physikerwelt: Looks good to me, approved jenkins-bot: Verified diff --git a/db/mathperformance.sql b/db/mathperformance.sql index 56a59b2..593056a 100644 --- a/db/mathperformance.sql +++ b/db/mathperformance.sql @@ -2,5 +2,6 @@ `math_inputhash` VARBINARY(16) NOT NULL, `mathperformance_name` CHAR(10) NOT NULL, `mathperformance_time` DOUBLE NOT NULL, + `mathperformance_mode` TINYINT NOT NULL, `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, INDEX `PK` (`math_inputhash` ASC, `mathperformance_name` ASC)); \ No newline at end of file diff --git a/maintenance/UpdateMath.php b/maintenance/UpdateMath.php index 9e1922d..f2bb6a0 100644 --- a/maintenance/UpdateMath.php +++ b/maintenance/UpdateMath.php @@ -32,6 +32,7 @@ private $current; private $time = 0;//microtime( true ); private $performance = array(); + private $renderingMode = MW_MATH_LATEXML; /** * @var DatabaseBase @@ -43,7 +44,7 @@ public function __construct() { $this->verbose = $this->verbose; parent::__construct(); - $this->mDescription = 'Outputs page text to stdout'; + $this->mDescription = 'Updates the index of Mathematical formulae.'; $this->addOption( 'purge', "If set all formulae are rendered again without using caches. (Very time consuming!)", false, false, "f" ); $this->addArg( 'min', "If set processing is started at the page with rank(pageID)>min", false ); $this->addArg( 'max', "If set processing is stopped at the page with rank(pageID)<=max", false ); @@ -51,6 +52,7 @@ $this->addOption( 'SVG', "If set SVG images will be produced", false, false ); $this->addOption( 'hoooks', "If set hooks will be skipped", false, false ); $this->addOption( 'texvccheck', "If set texvccheck will be skipped", false, false ); + $this->addOption( 'mode' , 'Rendering mode to be used (0 = PNG, 5= MathML, 7=MathML)',false,true,'m'); } private function time($category='default'){ global $wgMathDebug; @@ -63,7 +65,8 @@ $this->db->insert('mathperformance',array( 'math_inputhash' => $this->current->getInputHash(), 'mathperformance_name' => substr($category,0,10), - 'mathperformance_time' =>$delta, + 'mathperformance_time' => $delta, + 'mathperformance_mode' => $this->renderingMode )); } @@ -116,10 +119,11 @@ } /** - * @param unknown $pId + * @param $pid * @param unknown $pText * @param string $pTitle - * @param string $purge + * @internal param unknown $pId + * @internal param string $purge * @return number */ private function doUpdate( $pid, $pText, $pTitle = "") { @@ -132,7 +136,7 @@ echo( "\t processing $matches math fields for {$pTitle} page\n" ); foreach ( $math as $formula ) { $this->time = microtime(true); - $renderer = MathRenderer::getRenderer( $formula[1], $formula[2], MW_MATH_LATEXML ); + $renderer = MathRenderer::getRenderer( $formula[1], $formula[2], $this->renderingMode ); $this->current = $renderer; $this->time("loadClass"); if ( $this->getOption( "texvccheck", false ) ) { @@ -144,9 +148,9 @@ if ( $checked ) { $renderer->render( $this->purge ); if( $renderer->getMathml() ){ - $this->time("LaTeXML-Rendering"); + $this->time("Rendering"); } else { - $this->time("LaTeXML-Fail"); + $this->time("Failing"); } if ( $this->getOption( "SVG", false ) ) { $svg = $renderer->getSvg(); @@ -156,7 +160,7 @@ $this->time( "SVG-Fail" ); } } - }else{ + } else { $this->time("checkTex-Fail"); echo "\nF:\t\t".$renderer->getMd5()." texvccheck error:" . $renderer->getLastError(); continue; @@ -191,8 +195,9 @@ $this->dbw = wfGetDB( DB_MASTER ); $this->purge = $this->getOption( "purge", false ); $this->verbose = $this->getOption("verbose",false); + $this->renderingMode = $this->getOption( "mode" , 7); $this->db = wfGetDB( DB_MASTER ); - $wgMathValidModes[] = MW_MATH_LATEXML; + $wgMathValidModes[] = $this->renderingMode; $this->output( "Loaded.\n" ); $this->time = microtime( true ); $this->populateSearchIndex( $this->getArg( 0, 0 ), $this->getArg( 1, -1 ) ); -- To view, visit https://gerrit.wikimedia.org/r/173292 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I074d3938c2898f4124f1b5ad11186863b0455172 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/MathSearch Gerrit-Branch: master Gerrit-Owner: Physikerwelt <w...@physikerwelt.de> Gerrit-Reviewer: Physikerwelt <w...@physikerwelt.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits