Page MenuHomePhabricator

Error when installing Math extension with MediaWiki on PHP 8
Closed, ResolvedPublic1 Estimated Story PointsBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):

  • When installing MediaWiki on PHP 8, choose to install the Math extension. (regardless of web installer or CLI)

What happens?: The following error occurs:

[96336f8be79bfcf875dcef7b] [no req]   TypeError: array_map(): Argument #2 ($array) must be of type array, null given
Backtrace:
from C:\inetpub\wwwroot\w\extensions\Math\src\Hooks.php(48)
#0 C:\inetpub\wwwroot\w\extensions\Math\src\Hooks.php(48): array_map()
#1 C:\inetpub\wwwroot\w\includes\HookContainer\HookContainer.php(338): MediaWiki\Extension\Math\Hooks::onLoadExtensionSchemaUpdates()
#2 C:\inetpub\wwwroot\w\includes\HookContainer\HookContainer.php(137): MediaWiki\HookContainer\HookContainer->callLegacyHook()
#3 C:\inetpub\wwwroot\w\includes\HookContainer\HookRunner.php(2333): MediaWiki\HookContainer\HookContainer->run()
#4 C:\inetpub\wwwroot\w\includes\installer\DatabaseUpdater.php(142): MediaWiki\HookContainer\HookRunner->onLoadExtensionSchemaUpdates()
#5 C:\inetpub\wwwroot\w\includes\installer\DatabaseUpdater.php(500): DatabaseUpdater->loadExtensionSchemaUpdates()
#6 C:\inetpub\wwwroot\w\includes\installer\DatabaseInstaller.php(349): DatabaseUpdater->doUpdates()
#7 C:\inetpub\wwwroot\w\includes\installer\Installer.php(1680): DatabaseInstaller->createExtensionTables()
#8 C:\inetpub\wwwroot\w\includes\installer\CliInstaller.php(211): Installer->performInstallation()
#9 C:\inetpub\wwwroot\w\maintenance\install.php(144): CliInstaller->execute()
#10 C:\inetpub\wwwroot\w\maintenance\doMaintenance.php(114): CommandLineInstaller->execute()
#11 C:\inetpub\wwwroot\w\maintenance\install.php(205): require_once(string)
#12 {main}

What should have happened instead?: It must be installed normally without errors.

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc.: MediaWiki 1.38.0-rc.0, Windows Server vNext (Build 25110), IIS, MariaDB 10.6.7 and PHP 8.1.5.

캡처.PNG (1×1 px, 166 KB)

Event Timeline

Bluehill395 renamed this task from When installing MediaWiki on Windows, selecting the Math extension throws an error. to Error when installing Math extension with MediaWiki on Windows.May 9 2022, 9:27 AM

The localsettings were not created because it was an error during mediawiki installation. (not database updates)

Physikerwelt moved this task from Inbox to Next-up on the Math board.
Physikerwelt set the point value for this task to 1.

So this is a fresh installation and you downloaded the release version. I will try to reproduce it will take a few days until I come to it...

Unfortunately, I can not reproduce the problem. For me, it works well on Windows. Could you provide step-by-step instructions on how you configure your environment? The MediaWiki help page is unfortunately not very helpful if one wants to install MW on Windows.

I have set up IIS, PHP, MariaDB following the instructions outlined here. (The title is Server "2016", but it worked fine on newer Windows as well.) Also, I downloaded the zip from here and didn't use git. Just in case, I will try Git's REL1_38 branch.

I downloaded using Git, but the same thing happened.

Can you install without MathExtension being enabled and enable Math in a subsequent step?

Ok. In the meantime I was able to reproduce the error, thank you for the download link.

Bluehill395 renamed this task from Error when installing Math extension with MediaWiki on Windows to Error when installing Math extension with MediaWiki on PHP 8.Jun 1 2022, 2:01 AM

I found out that there is a problem not only with Windows but also with Ubuntu, and I looked into it and found out that there is a problem when using PHP 8. I tried PHP 7.4, but there is no problem.

I don't know how to fix this. It uses globals ($wgMathValidModes;) to get the math modes that are null if the web updater is used. One can not avoid globals via MediaWiki\MediaWikiServices::getInstance()->getMainConfig() as the hook runs before services are initialized. At least that is how I interpret the comment

		// This hook runs before services are initialized, so we cannot
		// use MathConfig service directly.

On the contrary, looking at https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+blame/master/includes/installer/DatabaseUpdater.php it seems that the config should be accessible.

What one could do is a workaround like if is_null($wgMathValidModes) create tables for all possible modes, or just create all tables regardless of the rendering modes. Would that be acceptable?

A possible suggestion is to just remove the $wgMathValidModes global from the onLoadExtensionSchemaUpdates hook handler and always create the two database tables mathlatexml and mathoid. Yea, they might go unused. But that shouldn't be a problem.

What if somebody decides to enable one of the two modes latexml or mathml on a wiki that was originally set up with these modes disabled? As of now you would run into unexpected exceptions that can only be resolved by running update.php again to create the missing database table(s). That's unexpected, in my opinion. The current behavior is not consistent anyway because there is no code (as far as I can see) that deletes a table when I disable one of these modes. So why bother partly "optimizing" the first update.php run like this?

@thiemowmde thank you. Exactly. I will change this.

Change 802056 had a related patch set uploaded (by Physikerwelt; author: Physikerwelt):

[mediawiki/extensions/Math@master] Set up mathoid and mathlatexml regardless of configuration

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

Change 802056 merged by jenkins-bot:

[mediawiki/extensions/Math@master] Set up mathoid and mathlatexml regardless of configuration

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

@Bluehill395 with the latest master the error should no longer appear. Are you able to test with the latest master, or do you need this change to be backported to the 1_38 release?

Change 802108 had a related patch set uploaded (by Physikerwelt; author: Physikerwelt):

[mediawiki/extensions/Math@REL1_38] Set up mathoid and mathlatexml regardless of configuration

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

I guess given that 1_38 is the first release (T232948) with Math bundled it makes perfect sense to backport the change to the 1_38 release branch.

Change 802108 merged by jenkins-bot:

[mediawiki/extensions/Math@REL1_38] Set up mathoid and mathlatexml regardless of configuration

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

@thiemowmde Thank you again for helping us.

Works on master branch and PHP 8.1.6.