Page MenuHomePhabricator

TypeError: Argument 1 passed to MediaWiki\Extension\DiscussionTools\LanguageData::convertDateFormat() must be of the type string, null given
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   TypeError: Argument 1 passed to MediaWiki\Extension\DiscussionTools\LanguageData::convertDateFormat() must be of the type string, null given, called in /srv/mediawiki/php-1.41.0-wmf.20/extensions/DiscussionTools/includes/LanguageData.php on line 54
exception.trace
from /srv/mediawiki/php-1.41.0-wmf.20/extensions/DiscussionTools/includes/LanguageData.php(158)
#0 /srv/mediawiki/php-1.41.0-wmf.20/extensions/DiscussionTools/includes/LanguageData.php(54): MediaWiki\Extension\DiscussionTools\LanguageData->convertDateFormat(NULL, TrivialLanguageConverter, string)
#1 /srv/mediawiki/php-1.41.0-wmf.20/extensions/DiscussionTools/includes/ResourceLoaderData.php(48): MediaWiki\Extension\DiscussionTools\LanguageData->getLocalData()
#2 /srv/mediawiki/php-1.41.0-wmf.20/includes/ResourceLoader/FileModule.php(1365): MediaWiki\Extension\DiscussionTools\ResourceLoaderData::getLocalData(MediaWiki\ResourceLoader\Context, GlobalVarConfig, NULL)
#3 /srv/mediawiki/php-1.41.0-wmf.20/includes/ResourceLoader/FileModule.php(1228): MediaWiki\ResourceLoader\FileModule->expandFileInfo(MediaWiki\ResourceLoader\Context, array, string)
#4 /srv/mediawiki/php-1.41.0-wmf.20/includes/ResourceLoader/FileModule.php(626): MediaWiki\ResourceLoader\FileModule->expandPackageFiles(MediaWiki\ResourceLoader\Context)
#5 /srv/mediawiki/php-1.41.0-wmf.20/includes/ResourceLoader/Module.php(929): MediaWiki\ResourceLoader\FileModule->getDefinitionSummary(MediaWiki\ResourceLoader\Context)
#6 /srv/mediawiki/php-1.41.0-wmf.20/includes/ResourceLoader/StartUpModule.php(231): MediaWiki\ResourceLoader\Module->getVersionHash(MediaWiki\ResourceLoader\Context)
#7 /srv/mediawiki/php-1.41.0-wmf.20/includes/ResourceLoader/StartUpModule.php(420): MediaWiki\ResourceLoader\StartUpModule->getModuleRegistrations(MediaWiki\ResourceLoader\Context)
#8 /srv/mediawiki/php-1.41.0-wmf.20/includes/ResourceLoader/Module.php(817): MediaWiki\ResourceLoader\StartUpModule->getScript(MediaWiki\ResourceLoader\Context)
#9 /srv/mediawiki/php-1.41.0-wmf.20/includes/ResourceLoader/Module.php(786): MediaWiki\ResourceLoader\Module->buildContent(MediaWiki\ResourceLoader\Context)
#10 /srv/mediawiki/php-1.41.0-wmf.20/includes/ResourceLoader/Module.php(926): MediaWiki\ResourceLoader\Module->getModuleContent(MediaWiki\ResourceLoader\Context)
#11 /srv/mediawiki/php-1.41.0-wmf.20/includes/ResourceLoader/ResourceLoader.php(686): MediaWiki\ResourceLoader\Module->getVersionHash(MediaWiki\ResourceLoader\Context)
#12 [internal function]: MediaWiki\ResourceLoader\ResourceLoader->MediaWiki\ResourceLoader\{closure}(string)
#13 /srv/mediawiki/php-1.41.0-wmf.20/includes/ResourceLoader/ResourceLoader.php(684): array_map(Closure, array)
#14 /srv/mediawiki/php-1.41.0-wmf.20/includes/ResourceLoader/ResourceLoader.php(785): MediaWiki\ResourceLoader\ResourceLoader->getCombinedVersion(MediaWiki\ResourceLoader\Context, array)
#15 /srv/mediawiki/php-1.41.0-wmf.20/load.php(53): MediaWiki\ResourceLoader\ResourceLoader->respond(MediaWiki\ResourceLoader\Context)
#16 /srv/mediawiki/php-1.41.0-wmf.20/load.php(39): wfLoadMain()
#17 /srv/mediawiki/w/load.php(3): require(string)
#18 {main}
Notes

217 of these in the last 8 hours. Only for wa.wikibooks.org.

Event Timeline

matmarex subscribed.

This indicates that Language::getDateFormatString() is returning null, which should not be possible.

Reedy renamed this task from TypeError: Argument 1 passed to MediaWiki\Extension\DiscussionTools\LanguageData::convertDateFormat() must be of the type string, null given, called in /srv/mediawiki/php-1.41.0-wmf.20/extensions/DiscussionTools/includes/Langua to TypeError: Argument 1 passed to MediaWiki\Extension\DiscussionTools\LanguageData::convertDateFormat() must be of the type string, null given.Aug 2 2023, 5:38 PM

@matmarex it's not documented as being able to return null, but it looks like it might in the case of a misconfiguration. I'm not super-familiar with how these are supposed to be set up, but I'm a bit suspicious of how MessagesWa.php contains:

$dateFormats = [
	'walloon short time' => 'H:i'
];

Every other Messages*.php file I checked that defines custom dateFormats specifies a date and both variant as well. (And generally a pretty.)

Change 945001 had a related patch set uploaded (by DLynch; author: DLynch):

[mediawiki/core@master] Fill out incomplete dateformat definition for "walloon short"

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

This might have the same root cause as T343375 – I was able to reproduce at https://wa.wikibooks.org/ yesterday, but not today, and it would make sense that this would be some kind of a localisation cache issue.

I haven’t been able to reproduce this locally yet, even after installing DiscussionTools and going back to a MediaWiki core version where the bad change from T342418 wasn’t reverted yet. Have you been able to reproduce it?

Change 945763 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/core@master] LocalisationCache: Add tests for preload behavior

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

Change 945764 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/core@master] LocalisationCache: Correctly merge preload data

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

Change 945765 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/core@master] LocalisationCache: Load only core data if possible (v2)

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

I haven’t been able to reproduce this locally yet, even after installing DiscussionTools and going back to a MediaWiki core version where the bad change from T342418 wasn’t reverted yet. Have you been able to reproduce it?

I couldn't reproduce it locally either.

I'm not super-familiar with how these are supposed to be set up, but I'm a bit suspicious of how MessagesWa.php contains:

$dateFormats = [
	'walloon short time' => 'H:i'
];

Every other Messages*.php file I checked that defines custom dateFormats specifies a date and both variant as well. (And generally a pretty.)

This worked because Language::getDateFormatString() guards against the date format being null for non-default values of $pref. It falls back to the default, which is dmy, which comes from French.

The actual cause is faulty preload merging.

Change 945001 merged by jenkins-bot:

[mediawiki/core@master] Fill out incomplete dateformat definition for "walloon short"

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

Change 945763 merged by jenkins-bot:

[mediawiki/core@master] LocalisationCache: Add tests for preload behavior

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

Change 945764 merged by jenkins-bot:

[mediawiki/core@master] LocalisationCache: Correctly merge preload data

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

Change 945765 merged by jenkins-bot:

[mediawiki/core@master] LocalisationCache: Load only core data if possible (v2)

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

There’s no beta wawikibooks, so I don’t know if we can verify this is fixed before the train rolls out next week. (Also, the “Fill out incomplete dateformat definition” change might “mask” the error anyways.)