Page MenuHomePhabricator

Extension:Math => Cannot save page when Math/Chem formula is used (using PHP8.0)
Closed, ResolvedPublicBUG REPORT

Description

Following exception occurs when you try to save the page containing a math formula:

[a5e4963e2b67c0bb27dfbbaf] [no req]   TypeError from line 69 of /data/codebase/w/extensions/Math/src/MathMathMLCli.php: array_key_exists(): Argument #2 ($array) must be of type array, stdClass given</p><p>Backtrace:</p><p>#0 /data/codebase/w/extensions/Math/src/MathMathMLCli.php(36): MathMathMLCli-&gt;initializeFromCliResponse()<br />
#1 /data/codebase/w/extensions/Math/src/MathHooks.php(354): MathMathMLCli::batchEvaluate()<br />
#2 /data/codebase/w/includes/HookContainer/HookContainer.php(329): MathHooks::onParserAfterTidy()<br />
#3 /data/codebase/w/includes/HookContainer/HookContainer.php(132): MediaWiki\HookContainer\HookContainer-&gt;callLegacyHook()<br />
#4 /data/codebase/w/includes/HookContainer/HookRunner.php(2895): MediaWiki\HookContainer\HookContainer-&gt;run()<br />
#5 /data/codebase/w/includes/parser/Parser.php(1693): MediaWiki\HookContainer\HookRunner-&gt;onParserAfterTidy()<br />
#6 /data/codebase/w/includes/parser/Parser.php(654): Parser-&gt;internalParseHalfParsed()<br />
#7 /data/codebase/w/includes/cache/MessageCache.php(1318): Parser-&gt;parse()<br />

Traced it to https://github.com/wikimedia/mediawiki-extensions-Math/blob/master/src/MathMathMLCli.php#L73, where stdClass is passed instead of array.
Since this is not a new change, i can only assume that it threw a warning in <PHP8, but in 8.0 it fatals.

Reproduced on 1.35.8 (ab62807), but bug exists in all branches

Event Timeline

Change 854519 had a related patch set uploaded (by ItSpiderman; author: ItSpiderman):

[mediawiki/extensions/Math@master] Fix calling array function on stdClass

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

Yes, I did not test with PHP8. Probably, I was under the assumption that json_decode would use JSON_OBJECT_AS_ARRAY as default which is apparently not the case.

Change 854519 merged by jenkins-bot:

[mediawiki/extensions/Math@master] Fix calling array function on stdClass

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

Change 854084 had a related patch set uploaded (by Reedy; author: ItSpiderman):

[mediawiki/extensions/Math@REL1_39] Fix calling array function on stdClass

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

Change 854085 had a related patch set uploaded (by Reedy; author: ItSpiderman):

[mediawiki/extensions/Math@REL1_38] Fix calling array function on stdClass

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

Change 854586 had a related patch set uploaded (by Reedy; author: ItSpiderman):

[mediawiki/extensions/Math@REL1_37] Fix calling array function on stdClass

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

Change 854587 had a related patch set uploaded (by Reedy; author: ItSpiderman):

[mediawiki/extensions/Math@REL1_35] Fix calling array function on stdClass

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

Change 854085 merged by jenkins-bot:

[mediawiki/extensions/Math@REL1_38] Fix calling array function on stdClass

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

Change 854586 merged by jenkins-bot:

[mediawiki/extensions/Math@REL1_37] Fix calling array function on stdClass

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

Change 854084 merged by jenkins-bot:

[mediawiki/extensions/Math@REL1_39] Fix calling array function on stdClass

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

Change 854587 merged by jenkins-bot:

[mediawiki/extensions/Math@REL1_35] Fix calling array function on stdClass

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

Reedy assigned this task to Dsavuljesku.