Page MenuHomePhabricator

PHP Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   PHP Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated
FrameLocationCall
from/srv/mediawiki/php-1.44.0-wmf.13/extensions/Wikibase/repo/includes/Parsers/DateFormatParser.php(144)
#0[internal function]MWExceptionHandler::handleError(int, string, string, int)
#1/srv/mediawiki/php-1.44.0-wmf.13/extensions/Wikibase/repo/includes/Parsers/DateFormatParser.php(144)strlen(null)
#2/srv/mediawiki/php-1.44.0-wmf.13/extensions/Wikibase/repo/includes/Parsers/DateFormatParser.php(348)Wikibase\Repo\Parsers\DateFormatParser->parseDateFormat(null)
#3/srv/mediawiki/php-1.44.0-wmf.13/extensions/Wikibase/repo/includes/Parsers/DateFormatParser.php(76)Wikibase\Repo\Parsers\DateFormatParser->parseDate(string)
#4/srv/mediawiki/php-1.44.0-wmf.13/vendor/data-values/common/src/ValueParsers/StringValueParser.php(47)Wikibase\Repo\Parsers\DateFormatParser->stringParse(string)
#5/srv/mediawiki/php-1.44.0-wmf.13/vendor/data-values/common/src/ValueParsers/DispatchingValueParser.php(60)ValueParsers\StringValueParser->parse(string)
#6/srv/mediawiki/php-1.44.0-wmf.13/extensions/Wikibase/repo/includes/Api/ParseValue.php(264)ValueParsers\DispatchingValueParser->parse(string)
#7/srv/mediawiki/php-1.44.0-wmf.13/extensions/Wikibase/repo/includes/Api/ParseValue.php(160)Wikibase\Repo\Api\ParseValue->parseStringValue(ValueParsers\DispatchingValueParser, string, null)
#8/srv/mediawiki/php-1.44.0-wmf.13/includes/api/ApiMain.php(1973)Wikibase\Repo\Api\ParseValue->execute()
#9/srv/mediawiki/php-1.44.0-wmf.13/includes/api/ApiMain.php(941)MediaWiki\Api\ApiMain->executeAction()
#10/srv/mediawiki/php-1.44.0-wmf.13/includes/api/ApiMain.php(912)MediaWiki\Api\ApiMain->executeActionWithErrorHandling()
#11/srv/mediawiki/php-1.44.0-wmf.13/includes/api/ApiEntryPoint.php(152)MediaWiki\Api\ApiMain->execute()
#12/srv/mediawiki/php-1.44.0-wmf.13/includes/MediaWikiEntryPoint.php(202)MediaWiki\Api\ApiEntryPoint->execute()
#13/srv/mediawiki/php-1.44.0-wmf.13/api.php(44)MediaWiki\MediaWikiEntryPoint->run()
#14/srv/mediawiki/w/api.php(3)require(string)
#15{main}
Impact
Notes

Event Timeline

This might not be a Wikibase bug but rather a Language bug where getDateFormatString returns null for certain input combinations.

The request where the notice occurred requested parsing in Japanese, so I created a script to figure out what combinations might be failing:

		$ja = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'ja' );
		$opts = ArrayUtils::cartesianProduct( [ 'time', 'date', 'monthonly', 'both', 'pretty' ], [ 'mdy', 'dmy', 'ymd', 'ISO 8601', 'default' ] );
		foreach ( $opts as [ $type, $pref ] ) {
			$str = $ja->getDateFormatString( $type, $pref );
			if ( $str === null ) {
				var_dump( $type );
				var_dump( $pref );
				break;
			}
		}

which gives monthonly + default.

Looks like @matmarex foresaw exactly this failure mode in code review comments when the monthonly date format was added 12 years ago: https://gerrit.wikimedia.org/r/c/mediawiki/core/+/77059. The issue here specifically seems to be that the default date format for Japanese is ja, so the EN fallback looks for ja monthonly which of course won't be defined among English date formats.

I suppose the ultimate fix here would be to add appropriate monthonly dateformats for each language.

Looks like this combination is broken in 66 languages (as reported by

):

ami: monthonly default is broken
blk: monthonly default is broken
ce: monthonly default is broken
cpx: monthonly default is broken
cpx-hans: monthonly default is broken
cpx-hant: monthonly default is broken
cs: monthonly default is broken
fi: monthonly default is broken
fit: monthonly default is broken
fy: monthonly default is broken
gan: monthonly default is broken
gan-hans: monthonly default is broken
gan-hant: monthonly default is broken
hak: monthonly default is broken
hr: monthonly default is broken
hsn: monthonly default is broken
ii: monthonly default is broken
is: monthonly default is broken
ja: monthonly default is broken
kjp: monthonly default is broken
km: monthonly default is broken
ko: monthonly default is broken
ko-kp: monthonly default is broken
krl: monthonly default is broken
ksw: monthonly default is broken
lzh: monthonly default is broken
mnw: monthonly default is broken
my: monthonly default is broken
nan: monthonly default is broken
nn: monthonly default is broken
oc: monthonly default is broken
olo: monthonly default is broken
pnt: monthonly default is broken
pwn: monthonly default is broken
rki: monthonly default is broken
rsk: monthonly default is broken
sl: monthonly default is broken
sr: monthonly default is broken
sr-ec: monthonly default is broken
sr-el: monthonly default is broken
szy: monthonly default is broken
tay: monthonly default is broken
th: monthonly default is broken
trv: monthonly default is broken
vi: monthonly default is broken
vo: monthonly default is broken
vot: monthonly default is broken
wuu: monthonly default is broken
wuu-hans: monthonly default is broken
wuu-hant: monthonly default is broken
yue: monthonly default is broken
yue-hans: monthonly default is broken
yue-hant: monthonly default is broken
za: monthonly default is broken
zh: monthonly default is broken
zh-classical: monthonly default is broken
zh-cn: monthonly default is broken
zh-hans: monthonly default is broken
zh-hant: monthonly default is broken
zh-hk: monthonly default is broken
zh-min-nan: monthonly default is broken
zh-mo: monthonly default is broken
zh-my: monthonly default is broken
zh-sg: monthonly default is broken
zh-tw: monthonly default is broken
zh-yue: monthonly default is broken
Total broken: 66

Change #1114958 had a related patch set uploaded (by Jon Harald Søby; author: Jon Harald Søby):

[mediawiki/core@master] Add monthonly date format to MessagesNn.php

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

Change #1114958 merged by jenkins-bot:

[mediawiki/core@master] Add monthonly date format to MessagesNn.php

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

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

[mediawiki/extensions/Wikibase@master] Handle null date format in MwDateFormatParserFactory

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

Change #1114993 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Handle null date format in MwDateFormatParserFactory

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

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

[mediawiki/extensions/Wikibase@wmf/1.44.0-wmf.14] Handle null date format in MwDateFormatParserFactory

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

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

[mediawiki/extensions/Wikibase@wmf/1.44.0-wmf.13] Handle null date format in MwDateFormatParserFactory

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

Change #1115012 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@wmf/1.44.0-wmf.13] Handle null date format in MwDateFormatParserFactory

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

Change #1115010 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@wmf/1.44.0-wmf.14] Handle null date format in MwDateFormatParserFactory

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

Reproduction steps:

curl -H 'X-Wikimedia-Debug: backend=k8s-mwdebug-next' 'https://www.wikidata.org/w/api.php?action=wbparsevalue&errorformat=plaintext&format=json&options=%7B%22lang%22%3A%22ja%22%7D&parser=time&uselang=ja&values=%1F2016'

Mentioned in SAL (#wikimedia-operations) [2025-01-29T14:46:04Z] <lucaswerkmeister-wmde@deploy2002> Started scap sync-world: Backport for [[gerrit:1114995|Handle missing monthonly format in MwTimeIsoFormatter (T384867)]], [[gerrit:1114994|Handle missing monthonly format in MwTimeIsoFormatter (T384867)]], [[gerrit:1115012|Handle null date format in MwDateFormatParserFactory (T384963)]], [[gerrit:1115010|Handle null date format in MwDateFormatParserFactory (T384963)]]

Mentioned in SAL (#wikimedia-operations) [2025-01-29T14:50:32Z] <lucaswerkmeister-wmde@deploy2002> lucaswerkmeister-wmde: Backport for [[gerrit:1114995|Handle missing monthonly format in MwTimeIsoFormatter (T384867)]], [[gerrit:1114994|Handle missing monthonly format in MwTimeIsoFormatter (T384867)]], [[gerrit:1115012|Handle null date format in MwDateFormatParserFactory (T384963)]], [[gerrit:1115010|Handle null date format in MwDateFormatParserFactory (T384963)]] synced to the

Mentioned in SAL (#wikimedia-operations) [2025-01-29T14:58:25Z] <lucaswerkmeister-wmde@deploy2002> Finished scap sync-world: Backport for [[gerrit:1114995|Handle missing monthonly format in MwTimeIsoFormatter (T384867)]], [[gerrit:1114994|Handle missing monthonly format in MwTimeIsoFormatter (T384867)]], [[gerrit:1115012|Handle null date format in MwDateFormatParserFactory (T384963)]], [[gerrit:1115010|Handle null date format in MwDateFormatParserFactory (T384963)]] (duration:

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

[mediawiki/extensions/Wikibase@REL1_43] Handle null date format in MwDateFormatParserFactory

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

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

[mediawiki/extensions/Wikibase@REL1_42] Handle null date format in MwDateFormatParserFactory

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

Change #1115407 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@REL1_43] Handle null date format in MwDateFormatParserFactory

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

Change #1115434 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@REL1_42] Handle null date format in MwDateFormatParserFactory

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

Reedy changed the task status from Open to In Progress.Jan 31 2025, 1:08 PM

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

[mediawiki/extensions/Wikibase@REL1_39] Handle null date format in MwDateFormatParserFactory

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

Change #1116809 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@REL1_39] Handle null date format in MwDateFormatParserFactory

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