Page MenuHomePhabricator

RuntimeException when loading UploadWizard in MW1.35
Closed, ResolvedPublic

Description

After upgrading to MediaWiki 1.35, navigating to Special:UploadWizard is triggering a RuntimeException, and the UploadWizard does not load. This is occurring in Microsoft Edge, Google Chrome, and Mozilla Firefox. I've already tried re-downloading both the UploadWizard and MediaWiki 1.35. The issue occurs on a clean install with UploadWizard as the only
enabled extension. The stacktrace is as follows:

[a0d1130aa1f4c03602ee58ea] /load.php?lang=en&modules=ext.echo.api%2Cinit%7Cext.popups%7Cjquery%2Cmoment%2CmyUploadWizardResources%2Coojs%2Coojs-ui-core%2Coojs-ui-widgets%2Coojs-ui-windows%2Csite%7Cjquery.client%2Ccookie%2ClengthLimit%2CmakeCollapsible%2Cspinner%2CtextSelection%2Cthrottle-debounce%7Cjquery.makeCollapsible.styles%7Cmediawiki.ForeignApi%2CString%2CTitle%2CUri%2Capi%2Cbase%2Ccldr%2CconfirmCloseWindow%2Ccookie%2Cfeedback%2Chtmlform%2Cicon%2CjqueryMsg%2Clanguage%2CmessagePoster%2Cstorage%2Cuser%2Cutil%2Cwidgets%7Cmediawiki.ForeignApi.core%7Cmediawiki.editfont.styles%7Cmediawiki.libs.jpegmeta%2Cpluralruleparser%7Cmediawiki.page.ready%2Cstartup%7Cmediawiki.widgets.CategoryMultiselectWidget%2CDateInputWidget%2Cstyles%7Cmediawiki.widgets.DateInputWidget.styles%7Coojs-ui-core.icons%2Cstyles%7Coojs-ui-widgets.icons%7Coojs-ui-windows.icons%7Coojs-ui.styles.icons-content%2Cicons-editing-advanced%2Cicons-editing-core%2Cicons-interactions%2Cicons-location%2Cicons-moderation%2Cicons-movement%2Cindicators%7Cskins.metrolook.collapsibleNav%2Cjs%7Cuser.defaults&skin=metrolook&version=73320   RuntimeException from line 485 of C:\inetpub\khbetabase\mediawiki-1.35.0\includes\resourceloader\ResourceLoaderFileModule.php: ResourceLoaderFileModule::getFileContents: script file not found, or is not a file: "/C:\inetpub\khbetabase\mediawiki-1.35.0/resources/src/mediawiki.messagePoster/factory.js"
Backtrace:
#0 C:\inetpub\khbetabase\mediawiki-1.35.0\includes\resourceloader\ResourceLoaderFileModule.php(905): ResourceLoaderFileModule->getFileContents()
#1 C:\inetpub\khbetabase\mediawiki-1.35.0\includes\resourceloader\ResourceLoaderFileModule.php(362): ResourceLoaderFileModule->readScriptFiles()
#2 C:\inetpub\khbetabase\mediawiki-1.35.0\includes\resourceloader\ResourceLoaderModule.php(736): ResourceLoaderFileModule->getScript()
#3 C:\inetpub\khbetabase\mediawiki-1.35.0\includes\resourceloader\ResourceLoaderModule.php(704): ResourceLoaderModule->buildContent()
#4 C:\inetpub\khbetabase\mediawiki-1.35.0\includes\resourceloader\ResourceLoader.php(1191): ResourceLoaderModule->getModuleContent()
#5 C:\inetpub\khbetabase\mediawiki-1.35.0\includes\resourceloader\ResourceLoader.php(899): ResourceLoader->makeModuleResponse()
#6 C:\inetpub\khbetabase\mediawiki-1.35.0\load.php(51): ResourceLoader->respond()
#7 C:\inetpub\khbetabase\mediawiki-1.35.0\load.php(38): wfLoadMain()
#8 {main} load.php:14:48
    <anonymous> jQuery

I believe the issue is that it's calling a file and using a path starting with a /, which would be invalid in the Windows environment I'm working in. However, I don't know where this path and file are being called from. Users in the MediaWiki Discord server suggested it may be an issue with MW 1.35, on account that going to page /load.php?debug=true&lang=en&modules=messagePoster returns a "Missing" error. But so far, this has only triggered in the UploadWizard.

Event Timeline

matmarex added a subscriber: matmarex.

Looks like a problem with the definition of mediawiki.messagePoster in core MediaWiki.

Looks like a problem with the definition of mediawiki.messagePoster in core MediaWiki.

Any idea where that definition is located? I've tried poking around, but I haven't found yet where the issue might be.

Reedy added a subscriber: Reedy.

Looks like a problem with the definition of mediawiki.messagePoster in core MediaWiki.

Any idea where that definition is located? I've tried poking around, but I haven't found yet where the issue might be.

ServiceWiring.php

		$msgPosterAttrib = $extRegistry->getAttribute( 'MessagePosterModule' );
		$rl->register( 'mediawiki.messagePoster', [
			'localBasePath' => '',
			'debugRaw' => false,
			'scripts' => array_merge(
				[
					"$IP/resources/src/mediawiki.messagePoster/factory.js",
					"$IP/resources/src/mediawiki.messagePoster/MessagePoster.js",
					"$IP/resources/src/mediawiki.messagePoster/WikitextMessagePoster.js",
				],
				$msgPosterAttrib['scripts'] ?? []
			),
			'dependencies' => array_merge(
				[
					'oojs',
					'mediawiki.api',
					'mediawiki.ForeignApi',
				],
				$msgPosterAttrib['dependencies'] ?? []
			),
			'targets' => [ 'desktop', 'mobile' ],
		] );

Just to confirm, mediawiki-1.35.0/resources/src/mediawiki.messagePoster/factory.js does exist on disk, and look "right"?

Added in rMW34bff221badd: mediawiki.messagePoster: Introduce 'MessagePosterModule' extension attribute, T235315: Remove magic module loading of "mediawiki.messagePoster"

Using $IP in that code looks wrong to me. The paths in 'scripts' should be relative, and the base path should be defined instead using 'localBasePath'.

Change 636784 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/core@master] Fix base path handling for MessagePosterModule registration

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

I can't actually test this on Windows (well, not easily), but this should fix it. I'd appreciate if you could test.

Just tested this out this morning, and now I'm getting this HTTP 500 error:

Fatal error: Uncaught TypeError: Argument 1 passed to MediaWiki\User\UserFactory::__construct() must be an instance of MediaWiki\User\UserNameUtils, instance of Wikimedia\Rdbms\LoadBalancer given, called in C:\inetpub\01-khdatabase\mediawiki-1.35.0\includes\ServiceWiring.php on line 1362 and defined in C:\inetpub\01-khdatabase\mediawiki-1.35.0\includes\user\UserFactory.php:46 Stack trace: #0 C:\inetpub\01-khdatabase\mediawiki-1.35.0\includes\ServiceWiring.php(1362): MediaWiki\User\UserFactory->__construct() #1 C:\inetpub\01-khdatabase\mediawiki-1.35.0\vendor\wikimedia\services\src\ServiceContainer.php(447): Wikimedia\Services\ServiceContainer->{closure}() #2 C:\inetpub\01-khdatabase\mediawiki-1.35.0\vendor\wikimedia\services\src\ServiceContainer.php(416): Wikimedia\Services\ServiceContainer->createService() #3 C:\inetpub\01-khdatabase\mediawiki-1.35.0\includes\MediaWikiServices.php(1289): Wikimedia\Services\ServiceContainer->getService() #4 C:\inetpub\01-khdatabase\mediawiki-1.35.0\includes\ServiceWiring.php(136): MediaWi in C:\inetpub\01-khdatabase\mediawiki-1.35.0\includes\user\UserFactory.php on line 46

The site's not loading at all now.

Just to confirm, mediawiki-1.35.0/resources/src/mediawiki.messagePoster/factory.js does exist on disk, and look "right"?

I can also confirm that the Factory.js file exists where it would appear it should be.

Change 636799 had a related patch set uploaded (by Reedy; owner: Bartosz Dziewoński):
[mediawiki/core@REL1_35] Fix base path handling for MessagePosterModule registration

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

Your error makes it sound like you've taken the whole file from master, which will not work. In REL1_35, the LoadBalancer parameter isn't passed at all. It is in master, due to rMWe9c0f8236c5f: Migrate more User::newFrom* methods to UserFactory. See https://github.com/wikimedia/mediawiki/blob/master/includes/ServiceWiring.php#L1359-L1364

So, should I just be copying the changed text? Because yes, I was copying the whole file over.

Your error makes it sound like you've taken the whole file from master, which will not work. In REL1_35, the LoadBalancer parameter isn't passed at all. It is in master, due to rMWe9c0f8236c5f: Migrate more User::newFrom* methods to UserFactory. See https://github.com/wikimedia/mediawiki/blob/master/includes/ServiceWiring.php#L1359-L1364

So, should I just be copying the changed text? Because yes, I was copying the whole file over.

Yes, pretty much.

Or if you need to copy the whole text, use my cherry pick to REL1_35

Change 636799 had a related patch set uploaded (by Reedy; owner: Bartosz Dziewoński):
[mediawiki/core@REL1_35] Fix base path handling for MessagePosterModule registration

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

Alright, I copied just the text over, and that appears to have fixed the issue! I'm not seeing any errors come up in the web console, and the UploadWizard is working normally now! Thank you!

Change 636799 merged by jenkins-bot:
[mediawiki/core@REL1_35] Fix base path handling for MessagePosterModule registration

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

Change 636784 merged by jenkins-bot:
[mediawiki/core@master] Fix base path handling for MessagePosterModule registration

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

Reedy assigned this task to matmarex.