Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/204098

Change subject: Use namespaced \MediaWiki\Logger\LoggerFactory
......................................................................

Use namespaced \MediaWiki\Logger\LoggerFactory

Change-Id: I78fca87d87379a694662c1a4ecc42e9401fd4c2c
---
M Math.hooks.php
M MathInputCheckTexvc.php
M MathLaTeXML.php
M MathMathML.php
M MathRenderer.php
M MathTexvc.php
6 files changed, 54 insertions(+), 43 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Math 
refs/changes/98/204098/1

diff --git a/Math.hooks.php b/Math.hooks.php
index d1181c6..51f19ea 100644
--- a/Math.hooks.php
+++ b/Math.hooks.php
@@ -1,4 +1,6 @@
 <?php
+use MediaWiki\Logger\LoggerFactory;
+
 /**
  * MediaWiki math extension
  *
@@ -46,9 +48,9 @@
                                        $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 @@
                }
 
                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 @@
                // 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.
diff --git a/MathInputCheckTexvc.php b/MathInputCheckTexvc.php
index 38c9374..2e20630 100644
--- a/MathInputCheckTexvc.php
+++ b/MathInputCheckTexvc.php
@@ -1,4 +1,6 @@
 <?php
+use MediaWiki\Logger\LoggerFactory;
+
 /**
  * MediaWiki math extension
  *
@@ -62,7 +64,7 @@
                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 +75,12 @@
                        $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 +90,13 @@
 
                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;
diff --git a/MathLaTeXML.php b/MathLaTeXML.php
index 1d1ebb2..8f7cfa6 100644
--- a/MathLaTeXML.php
+++ b/MathLaTeXML.php
@@ -1,4 +1,6 @@
 <?php
+use MediaWiki\Logger\LoggerFactory;
+
 /**
  * MediaWiki math extension
  *
@@ -84,7 +86,7 @@
                $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 @@
                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 @@
                                        // 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 @@
                                }
                        } 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 @@
                        $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;
diff --git a/MathMathML.php b/MathMathML.php
index 1fd2fca..a6874fd 100644
--- a/MathMathML.php
+++ b/MathMathML.php
@@ -1,4 +1,6 @@
 <?php
+use MediaWiki\Logger\LoggerFactory;
+
 /**
  * MediaWiki math extension
  *
@@ -96,7 +98,7 @@
         * @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 +163,7 @@
                        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 +174,7 @@
                                $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 +197,7 @@
                } else {
                        $host = $this->hosts;
                }
-               MWLoggerFactory::getInstance( 'Math' )->debug( 'Picking host ' 
. $host );
+               LoggerFactory::getInstance( 'Math' )->debug( 'Picking host ' . 
$host );
                return $host;
        }
 
@@ -219,7 +221,7 @@
                                $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 +231,7 @@
         */
        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 +252,7 @@
                                                $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 +262,7 @@
                                }
                        } 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 +290,7 @@
 
                $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 +303,7 @@
                        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 +475,7 @@
                                        $this->setSvg( $jsonResult->svg );
                                }
                        } else {
-                               MWLoggerFactory::getInstance( 'Math' )->error(
+                               LoggerFactory::getInstance( 'Math' )->error(
                                        'Missing SVG property in JSON result.' 
);
                        }
                        if ( $wgMathDebug ) {
diff --git a/MathRenderer.php b/MathRenderer.php
index 0c85212..6cebb36 100644
--- a/MathRenderer.php
+++ b/MathRenderer.php
@@ -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 @@
                        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 @@
                # 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 @@
                                ) {
                                        $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 @@
                                ) {
                                        $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 @@
         * 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 @@
                // 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;
diff --git a/MathTexvc.php b/MathTexvc.php
index b5b660b..70f351c 100644
--- a/MathTexvc.php
+++ b/MathTexvc.php
@@ -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 @@
                $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 @@
                        $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 @@
        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 @@
 
                $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 @@
                        # 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' );
                        }

-- 
To view, visit https://gerrit.wikimedia.org/r/204098
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I78fca87d87379a694662c1a4ecc42e9401fd4c2c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Math
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to