jmnote / SimpleMathJax

MediaWiki Extension SimpleMathJax
https://www.mediawiki.org/wiki/Extension:SimpleMathJax
MIT License
30 stars 23 forks source link

Use of ParserOutput::addModules with non-array argument was deprecated in MediaWiki 1.38 #37

Closed noloader closed 2 years ago

noloader commented 2 years ago

We recently upgrade from Mediawiki 1.37 to 1.38. SimpleMathJax is causing an issue in ParserOutput extension:

Deprecated: Use of ParserOutput::addModules with non-array argument was deprecated in MediaWiki 1.38.
[Called from SimpleMathJaxHooks::renderTex in /var/www/html/w/extensions/SimpleMathJax/SimpleMathJaxHooks.php
at line 34] in /var/www/html/w/includes/debug/MWDebug.php on line 377

This seems to fix it:

# git diff
diff --git a/SimpleMathJaxHooks.php b/SimpleMathJaxHooks.php
index 71cc9488..e794a508
--- a/SimpleMathJaxHooks.php
+++ b/SimpleMathJaxHooks.php
@@ -31,8 +31,8 @@ class SimpleMathJaxHooks {
        }

        private static function renderTex($tex, $parser) {
-               $parser->getOutput()->addModules( 'ext.SimpleMathJax' );
-               $parser->getOutput()->addModules( 'ext.SimpleMathJax.mobile' ); // For MobileFrontend
+               $parser->getOutput()->addModules( [ 'ext.SimpleMathJax' ] );
+               $parser->getOutput()->addModules( [ 'ext.SimpleMathJax.mobile' ] ); // For MobileFrontend
                $attributes = [ "style" => "opacity:.5" ];
                Hooks::run( "SimpleMathJaxAttributes", [ &$attributes, $tex ] );
                $element = Html::Element( "span", $attributes, "[math]{$tex}[/math]" );

Here's the issue on our wiki:

parser-output-mw-138

noloader commented 2 years ago

Fixed in GH #34, but we need the PR merged.