Use namespaced \MediaWiki\Logger\LoggerFactory
Change-Id: I78fca87d87379a694662c1a4ecc42e9401fd4c2c
This commit is contained in:
parent
485267baaa
commit
241800f80d
|
@ -2,10 +2,12 @@
|
|||
/**
|
||||
* MediaWiki math extension
|
||||
*
|
||||
* (c) 2002-2014 various MediaWiki contributors
|
||||
* (c) 2002-2015 various MediaWiki contributors
|
||||
* GPLv2 license; info in main package.
|
||||
*/
|
||||
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
|
||||
class MathHooks {
|
||||
const mathCacheKey = 'math=';
|
||||
|
||||
|
@ -46,9 +48,9 @@ class MathHooks {
|
|||
$confstr .= '!' . self::mathCacheKey . $mathOption;
|
||||
}
|
||||
|
||||
MWLoggerFactory::getInstance( 'Math' )->debug( "New cache key: $confstr" );
|
||||
LoggerFactory::getInstance( 'Math' )->debug( "New cache key: $confstr" );
|
||||
} else {
|
||||
MWLoggerFactory::getInstance( 'Math' )->debug( "Cache key found: $confstr" );
|
||||
LoggerFactory::getInstance( 'Math' )->debug( "Cache key found: $confstr" );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,10 +119,10 @@ class MathHooks {
|
|||
}
|
||||
|
||||
if ( $renderer->render() ) {
|
||||
MWLoggerFactory::getInstance( 'Math' )->info( "Rendering successful. Writing output" );
|
||||
LoggerFactory::getInstance( 'Math' )->info( "Rendering successful. Writing output" );
|
||||
$renderedMath = $renderer->getHtmlOutput();
|
||||
} else {
|
||||
MWLoggerFactory::getInstance( 'Math' )->warning(
|
||||
LoggerFactory::getInstance( 'Math' )->warning(
|
||||
"Rendering failed. Printing error message." );
|
||||
return $renderer->getLastError();
|
||||
}
|
||||
|
@ -158,7 +160,7 @@ class MathHooks {
|
|||
// If the default option is not in the valid options the
|
||||
// user interface throws an exception (BUG 64844)
|
||||
if ( ! in_array( $wgDefaultUserOptions['math'] , $wgMathValidModes ) ) {
|
||||
MWLoggerFactory::getInstance( 'Math' )->error( 'Misconfiguration: '.
|
||||
LoggerFactory::getInstance( 'Math' )->error( 'Misconfiguration: '.
|
||||
"\$wgDefaultUserOptions['math'] is not in \$wgMathValidModes.\n".
|
||||
"Please check your LocalSetting.php file." );
|
||||
// Display the checkbox in the first option.
|
||||
|
|
|
@ -2,11 +2,14 @@
|
|||
/**
|
||||
* MediaWiki math extension
|
||||
*
|
||||
* (c) 2002-2013 Tomasz Wegrzanowski, Brion Vibber, Moritz Schubotz, and other MediaWiki contributors
|
||||
* (c) 2002-2015 Tomasz Wegrzanowski, Brion Vibber, Moritz Schubotz, and other MediaWiki contributors
|
||||
* GPLv2 license; info in main package.
|
||||
*
|
||||
* @author Moritz Schubotz
|
||||
*/
|
||||
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
|
||||
class MathInputCheckTexvc extends MathInputCheck {
|
||||
|
||||
/**
|
||||
|
@ -62,7 +65,7 @@ class MathInputCheckTexvc extends MathInputCheck {
|
|||
if ( !is_executable( $wgMathTexvcCheckExecutable ) ) {
|
||||
$msg = 'Missing "texvccheck" executable. Please see math/README to configure.';
|
||||
trigger_error( $msg, E_USER_NOTICE );
|
||||
MWLoggerFactory::getInstance( 'Math' )->error( $msg );
|
||||
LoggerFactory::getInstance( 'Math' )->error( $msg );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -73,12 +76,12 @@ class MathInputCheckTexvc extends MathInputCheck {
|
|||
$cmd = 'sh -c ' . wfEscapeShellArg( $cmd );
|
||||
}
|
||||
|
||||
MWLoggerFactory::getInstance( 'Math' )->debug( "TeX check command: $cmd" );
|
||||
LoggerFactory::getInstance( 'Math' )->debug( "TeX check command: $cmd" );
|
||||
$contents = wfShellExec( $cmd );
|
||||
MWLoggerFactory::getInstance( 'Math' )->debug( "TeX check result: $contents\n---" );
|
||||
LoggerFactory::getInstance( 'Math' )->debug( "TeX check result: $contents\n---" );
|
||||
|
||||
if ( strlen( $contents ) === 0 ) {
|
||||
MWLoggerFactory::getInstance( 'Math' )->warning( 'TeX check output was empty.' );
|
||||
LoggerFactory::getInstance( 'Math' )->warning( 'TeX check output was empty.' );
|
||||
$this->lastError = $this->convertTexvcError( $contents );
|
||||
|
||||
return false;
|
||||
|
@ -88,13 +91,13 @@ class MathInputCheckTexvc extends MathInputCheck {
|
|||
|
||||
if ( $retval !== '+' ) {
|
||||
$this->lastError = $this->convertTexvcError( $contents );
|
||||
MWLoggerFactory::getInstance( 'Math' )->warning( 'checkTex failed: ' . $this->lastError );
|
||||
LoggerFactory::getInstance( 'Math' )->warning( 'checkTex failed: ' . $this->lastError );
|
||||
|
||||
return false;
|
||||
} else {
|
||||
$this->validTeX = substr( $contents, 1 );
|
||||
$this->isValid = true;
|
||||
MWLoggerFactory::getInstance( 'Math' )->debug(
|
||||
LoggerFactory::getInstance( 'Math' )->debug(
|
||||
'checkTex successful tex is now: ' . $this->validTeX );
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
|
||||
/**
|
||||
* MediaWiki math extension
|
||||
*
|
||||
|
@ -84,7 +86,7 @@ class MathLaTeXML extends MathMathML {
|
|||
$texcmd = rawurlencode( $tex );
|
||||
$settings = $this->serializeSettings( $this->getLaTeXMLSettings() );
|
||||
$postData = $settings . '&tex=' . $texcmd;
|
||||
MWLoggerFactory::getInstance( 'Math' )->debug( 'Get post data: ' . $postData );
|
||||
LoggerFactory::getInstance( 'Math' )->debug( 'Get post data: ' . $postData );
|
||||
return $postData;
|
||||
}
|
||||
|
||||
|
@ -96,7 +98,7 @@ class MathLaTeXML extends MathMathML {
|
|||
global $wgMathDebug;
|
||||
|
||||
if ( trim( $this->getTex() ) === '' ) {
|
||||
MWLoggerFactory::getInstance( 'Math' )->warning(
|
||||
LoggerFactory::getInstance( 'Math' )->warning(
|
||||
'Rendering was requested, but no TeX string is specified.' );
|
||||
$this->lastError = $this->getError( 'math_empty_tex' );
|
||||
return false;
|
||||
|
@ -125,7 +127,7 @@ class MathLaTeXML extends MathMathML {
|
|||
// Do not print bad mathml. It's probably too verbose and might
|
||||
// mess up the browser output.
|
||||
$this->lastError = $this->getError( 'math_invalidxml', $this->getModeStr(), $host );
|
||||
MWLoggerFactory::getInstance( 'Math' )->warning(
|
||||
LoggerFactory::getInstance( 'Math' )->warning(
|
||||
'LaTeXML InvalidMathML: ' . var_export( array(
|
||||
'post' => $post,
|
||||
'host' => $host,
|
||||
|
@ -135,7 +137,7 @@ class MathLaTeXML extends MathMathML {
|
|||
}
|
||||
} else {
|
||||
$this->lastError = $this->getError( 'math_invalidjson', $this->getModeStr(), $host );
|
||||
MWLoggerFactory::getInstance( 'Math' )->warning(
|
||||
LoggerFactory::getInstance( 'Math' )->warning(
|
||||
'LaTeXML InvalidJSON:' . var_export( array(
|
||||
'post' => $post,
|
||||
'host' => $host,
|
||||
|
@ -191,7 +193,7 @@ class MathLaTeXML extends MathMathML {
|
|||
$this->svg = $renderer->getSvg();
|
||||
} else {
|
||||
$lastError = $renderer->getLastError();
|
||||
MWLoggerFactory::getInstance( 'Math' )->error(
|
||||
LoggerFactory::getInstance( 'Math' )->error(
|
||||
'Failed to convert LaTeXML-MathML to SVG:' . $lastError );
|
||||
}
|
||||
return $res;
|
||||
|
|
|
@ -2,11 +2,14 @@
|
|||
/**
|
||||
* MediaWiki math extension
|
||||
*
|
||||
* (c)2012 Moritz Schubotz
|
||||
* (c) 2002-2015 various MediaWiki contributors
|
||||
* GPLv2 license; info in main package.
|
||||
*
|
||||
* Contains the driver function for the MathML daemon
|
||||
* @file
|
||||
*/
|
||||
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
|
||||
/**
|
||||
* Converts LaTeX to MathML using the mathoid-server
|
||||
*/
|
||||
class MathMathML extends MathRenderer {
|
||||
|
||||
|
@ -96,7 +99,7 @@ class MathMathML extends MathRenderer {
|
|||
* @return boolean
|
||||
*/
|
||||
private function renderingRequired() {
|
||||
$logger = MWLoggerFactory::getInstance( 'Math' );
|
||||
$logger = LoggerFactory::getInstance( 'Math' );
|
||||
if ( $this->isPurge() ) {
|
||||
$logger->debug( 'Rerendering was requested.' );
|
||||
return true;
|
||||
|
@ -161,7 +164,7 @@ class MathMathML extends MathRenderer {
|
|||
if ( $status->hasMessage( 'http-timed-out' ) ) {
|
||||
$error = $this->getError( 'math_timeout', $this->getModeStr(), $host );
|
||||
$res = false;
|
||||
MWLoggerFactory::getInstance( 'Math' )->warning( 'Timeout:' . var_export( array(
|
||||
LoggerFactory::getInstance( 'Math' )->warning( 'Timeout:' . var_export( array(
|
||||
'post' => $post,
|
||||
'host' => $host,
|
||||
'timeout' => $wgMathLaTeXMLTimeout
|
||||
|
@ -172,7 +175,7 @@ class MathMathML extends MathRenderer {
|
|||
$error =
|
||||
$this->getError( 'math_invalidresponse', $this->getModeStr(), $host, $errormsg,
|
||||
$this->getModeStr( MW_MATH_MATHML ) );
|
||||
MWLoggerFactory::getInstance( 'Math' )->warning( 'NoResponse:' . var_export( array(
|
||||
LoggerFactory::getInstance( 'Math' )->warning( 'NoResponse:' . var_export( array(
|
||||
'post' => $post,
|
||||
'host' => $host,
|
||||
'errormsg' => $errormsg
|
||||
|
@ -195,7 +198,7 @@ class MathMathML extends MathRenderer {
|
|||
} else {
|
||||
$host = $this->hosts;
|
||||
}
|
||||
MWLoggerFactory::getInstance( 'Math' )->debug( 'Picking host ' . $host );
|
||||
LoggerFactory::getInstance( 'Math' )->debug( 'Picking host ' . $host );
|
||||
return $host;
|
||||
}
|
||||
|
||||
|
@ -219,7 +222,7 @@ class MathMathML extends MathRenderer {
|
|||
$out = 'type=tex&q=' . rawurlencode( $input );
|
||||
}
|
||||
}
|
||||
MWLoggerFactory::getInstance( 'Math' )->debug( 'Get post data: ' . $out );
|
||||
LoggerFactory::getInstance( 'Math' )->debug( 'Get post data: ' . $out );
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
@ -229,7 +232,7 @@ class MathMathML extends MathRenderer {
|
|||
*/
|
||||
protected function doRender() {
|
||||
if ( $this->getTex() === '' ) {
|
||||
MWLoggerFactory::getInstance( 'Math' )->debug( 'Rendering was requested, but no TeX string is specified.' );
|
||||
LoggerFactory::getInstance( 'Math' )->debug( 'Rendering was requested, but no TeX string is specified.' );
|
||||
$this->lastError = $this->getError( 'math_empty_tex' );
|
||||
return false;
|
||||
}
|
||||
|
@ -250,7 +253,7 @@ class MathMathML extends MathRenderer {
|
|||
$log = wfMessage( 'math_unknown_error' )->inContentLanguage()->escaped();
|
||||
}
|
||||
$this->lastError = $this->getError( 'math_mathoid_error', $host, $log );
|
||||
MWLoggerFactory::getInstance( 'Math' )->warning(
|
||||
LoggerFactory::getInstance( 'Math' )->warning(
|
||||
'Mathoid conversion error:' . var_export( array(
|
||||
'post' => $post,
|
||||
'host' => $host,
|
||||
|
@ -260,7 +263,7 @@ class MathMathML extends MathRenderer {
|
|||
}
|
||||
} else {
|
||||
$this->lastError = $this->getError( 'math_invalidjson', $host );
|
||||
MWLoggerFactory::getInstance( 'Math' )->error(
|
||||
LoggerFactory::getInstance( 'Math' )->error(
|
||||
'MathML InvalidJSON:' . var_export( array(
|
||||
'post' => $post,
|
||||
'host' => $host,
|
||||
|
@ -288,7 +291,7 @@ class MathMathML extends MathRenderer {
|
|||
|
||||
$xmlObject = new XmlTypeCheck( $XML, null, false );
|
||||
if ( !$xmlObject->wellFormed ) {
|
||||
MWLoggerFactory::getInstance( 'Math' )->error(
|
||||
LoggerFactory::getInstance( 'Math' )->error(
|
||||
'XML validation error: ' . var_export( $XML, true ) );
|
||||
} else {
|
||||
$name = $xmlObject->getRootElement();
|
||||
|
@ -301,7 +304,7 @@ class MathMathML extends MathRenderer {
|
|||
if ( in_array( $localName , $this->getAllowedRootElements() ) ) {
|
||||
$out = true;
|
||||
} else {
|
||||
MWLoggerFactory::getInstance( 'Math' )->error( "Got wrong root element : $name" );
|
||||
LoggerFactory::getInstance( 'Math' )->error( "Got wrong root element : $name" );
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
|
@ -473,7 +476,7 @@ class MathMathML extends MathRenderer {
|
|||
$this->setSvg( $jsonResult->svg );
|
||||
}
|
||||
} else {
|
||||
MWLoggerFactory::getInstance( 'Math' )->error(
|
||||
LoggerFactory::getInstance( 'Math' )->error(
|
||||
'Missing SVG property in JSON result.' );
|
||||
}
|
||||
if ( $wgMathDebug ) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* @file
|
||||
*/
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
|
||||
/**
|
||||
* Abstract base class with static methods for rendering the <math> tags using
|
||||
|
@ -172,7 +173,7 @@ abstract class MathRenderer {
|
|||
default:
|
||||
$renderer = new MathMathML( $tex, $params );
|
||||
}
|
||||
MWLoggerFactory::getInstance( 'Math' )->info( 'Start rendering $' . $renderer->tex .
|
||||
LoggerFactory::getInstance( 'Math' )->info( 'Start rendering $' . $renderer->tex .
|
||||
'$ in mode ' . $mode );
|
||||
$renderer->setMathStyle( $mathStyle );
|
||||
return $renderer;
|
||||
|
@ -328,7 +329,7 @@ abstract class MathRenderer {
|
|||
# Now save it back to the DB:
|
||||
if ( !wfReadOnly() ) {
|
||||
$dbw = $dbw ?: wfGetDB( DB_MASTER );
|
||||
MWLoggerFactory::getInstance( 'Math' )->info( 'Store entry for $' . $this->tex .
|
||||
LoggerFactory::getInstance( 'Math' )->info( 'Store entry for $' . $this->tex .
|
||||
'$ in database (hash:' . $this->getMd5() . ')' );
|
||||
$outArray = $this->dbOutArray();
|
||||
$method = __METHOD__;
|
||||
|
@ -340,7 +341,7 @@ abstract class MathRenderer {
|
|||
) {
|
||||
$dbw->update( $mathTableName, $outArray,
|
||||
array( 'math_inputhash' => $inputHash ), $method );
|
||||
MWLoggerFactory::getInstance( 'Math' )->debug(
|
||||
LoggerFactory::getInstance( 'Math' )->debug(
|
||||
'Row updated after db transaction was idle: ' .
|
||||
var_export( $outArray, true ) . " to database" );
|
||||
} );
|
||||
|
@ -350,12 +351,12 @@ abstract class MathRenderer {
|
|||
) {
|
||||
$dbw->insert( $mathTableName, $outArray, $method, array( 'IGNORE' ) );
|
||||
if ( $wgMathDebug ) {
|
||||
MWLoggerFactory::getInstance( 'Math' )->debug(
|
||||
LoggerFactory::getInstance( 'Math' )->debug(
|
||||
'Row inserted after db transaction was idle ' .
|
||||
var_export( $outArray, true ) . " to database" );
|
||||
if ( $dbw->affectedRows() == 0 ) {
|
||||
// That's the price for the delayed update.
|
||||
MWLoggerFactory::getInstance( 'Math' )->warning(
|
||||
LoggerFactory::getInstance( 'Math' )->warning(
|
||||
'Entry could not be written. Might be changed in between.' );
|
||||
}
|
||||
}
|
||||
|
@ -398,7 +399,7 @@ abstract class MathRenderer {
|
|||
* Writes cache. Writes the database entry if values were changed
|
||||
*/
|
||||
public function writeCache() {
|
||||
$logger = MWLoggerFactory::getInstance( 'Math' );
|
||||
$logger = LoggerFactory::getInstance( 'Math' );
|
||||
$logger->debug( 'Writing of cache requested.' );
|
||||
if ( $this->isChanged() ) {
|
||||
$logger->debug( 'Change detected. Perform writing.' );
|
||||
|
@ -526,7 +527,7 @@ abstract class MathRenderer {
|
|||
// until this issue is resolved we use ?mathpurge=true instead
|
||||
$mathpurge = $request->getBool( 'mathpurge', false );
|
||||
if ( $mathpurge ) {
|
||||
MWLoggerFactory::getInstance( 'Math' )->debug( 'Re-Rendering on user request' );
|
||||
LoggerFactory::getInstance( 'Math' )->debug( 'Re-Rendering on user request' );
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* Contains the driver function for the texvc program
|
||||
* @file
|
||||
*/
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
|
||||
/**
|
||||
* Takes LaTeX fragments, sends them to a helper program (texvc) for rendering
|
||||
* to rasterized PNG and HTML and MathML approximations. An appropriate
|
||||
|
@ -43,7 +45,7 @@ class MathTexvc extends MathRenderer {
|
|||
$out['math_html'] = $this->html;
|
||||
$out['math_mathml'] = utf8_encode( $this->getMathml() );
|
||||
$out['math_inputhash'] = $this->getInputHash();
|
||||
MWLoggerFactory::getInstance( 'Math' )->info( 'Store Hashpath of image' .
|
||||
LoggerFactory::getInstance( 'Math' )->info( 'Store Hashpath of image' .
|
||||
bin2hex( $outmd5_sql ) );
|
||||
return $out;
|
||||
}
|
||||
|
@ -65,7 +67,7 @@ class MathTexvc extends MathRenderer {
|
|||
$xhash = unpack( 'H32md5',
|
||||
$dbr->decodeBlob( $rpage->math_outputhash ) . " " );
|
||||
$this->hash = $xhash['md5'];
|
||||
MWLoggerFactory::getInstance( 'Math' )->info( 'Hashpath of PNG-File:' .
|
||||
LoggerFactory::getInstance( 'Math' )->info( 'Hashpath of PNG-File:' .
|
||||
bin2hex( $this->hash ) );
|
||||
$this->conservativeness = $rpage->math_html_conservativeness;
|
||||
$this->html = $rpage->math_html;
|
||||
|
@ -101,7 +103,7 @@ class MathTexvc extends MathRenderer {
|
|||
public function getHashPath() {
|
||||
$path = $this->getBackend()->getRootStoragePath() .
|
||||
'/math-render/' . $this->getHashSubPath();
|
||||
MWLoggerFactory::getInstance( 'Math' )->debug(
|
||||
LoggerFactory::getInstance( 'Math' )->debug(
|
||||
"TeX: getHashPath, hash is: {$this->getHash()}, path is: $path" );
|
||||
return $path;
|
||||
}
|
||||
|
@ -178,7 +180,7 @@ class MathTexvc extends MathRenderer {
|
|||
|
||||
$tmpDir = wfTempDir();
|
||||
if ( !is_executable( $wgTexvc ) ) {
|
||||
MWLoggerFactory::getInstance( 'Math' )->error(
|
||||
LoggerFactory::getInstance( 'Math' )->error(
|
||||
"$wgTexvc does not exist or is not executable." );
|
||||
return $this->getError( 'math_notexvc' );
|
||||
}
|
||||
|
@ -196,19 +198,19 @@ class MathTexvc extends MathRenderer {
|
|||
# Invoke it within cygwin sh, because texvc expects sh features in its default shell
|
||||
$cmd = 'sh -c ' . wfEscapeShellArg( $cmd );
|
||||
}
|
||||
MWLoggerFactory::getInstance( 'Math' )->debug( "TeX: $cmd" );
|
||||
MWLoggerFactory::getInstance( 'Math' )->debug( "Executing '$cmd'." );
|
||||
LoggerFactory::getInstance( 'Math' )->debug( "TeX: $cmd" );
|
||||
LoggerFactory::getInstance( 'Math' )->debug( "Executing '$cmd'." );
|
||||
$retval = null;
|
||||
$contents = wfShellExec( $cmd, $retval );
|
||||
MWLoggerFactory::getInstance( 'Math' )->debug( "TeX output:\n $contents\n---" );
|
||||
LoggerFactory::getInstance( 'Math' )->debug( "TeX output:\n $contents\n---" );
|
||||
|
||||
if ( strlen( $contents ) == 0 ) {
|
||||
if ( !file_exists( $tmpDir ) || !is_writable( $tmpDir ) ) {
|
||||
MWLoggerFactory::getInstance( 'Math' )->error(
|
||||
LoggerFactory::getInstance( 'Math' )->error(
|
||||
"TeX output directory $tmpDir is missing or not writable" );
|
||||
return $this->getError( 'math_bad_tmpdir' );
|
||||
} else {
|
||||
MWLoggerFactory::getInstance( 'Math' )->error(
|
||||
LoggerFactory::getInstance( 'Math' )->error(
|
||||
"TeX command '$cmd' returned no output and status code $retval." );
|
||||
return $this->getError( 'math_unknown_error' );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue