Page MenuHomePhabricator

SiteConfiguration arrayMerge() seems to corrupt numerical keys
Closed, ResolvedPublic

Description

As part of on-going optimisation at T169821, I noticed that one of my unmerged commits shows a dirty config diff, whereas the change is meant to be a no-op.

However, the change is not a breakage. It is actually concidentally avoiding a pre-existing bug that was previousliy corrupting the configuration arrays for many wg-variables that contain numerical keys. Typically those that use namespace constants as keys.

Observed problem

The wgNamespacesWithSubpages setting for many wikis has wrongly swapping various boolean true values to 0.

For example, for nlwikibooks the following is relevant from InitialiseSettings.php:

InitialiseSettings.php
'wgNamespacesWithSubpages' => [
	'default' => [
		NS_TALK /* 1 */ => true,
		NS_USER /* 2 */ => true,
		NS_USER_TALK /* 3 */ => true,
		NS_PROJECT /* 4 */ => true,
		NS_PROJECT_TALK /* 5 */ => true,
		NS_FILE_TALK /* 7 */ => true,
		NS_MEDIAWIKI /* 8 */ => true,
		NS_MEDIAWIKI_TALK /* 9 */ => true,
		NS_TEMPLATE /* 10 */ => true,
		NS_TEMPLATE_TALK /* 11 */ => true,
		NS_HELP /* 12 */ => true,
		NS_HELP_TALK /* 13 */ => true,
		NS_CATEGORY_TALK /* 15 */ => true,
		100 => true,
		101 => true,
		102 => true,
		103 => true,
		104 => true,
		105 => true,
		106 => true,
		107 => true,
		108 => true,
		109 => true,
		110 => true,
		111 => true,
		112 => true,
		113 => true,
		114 => true,
		115 => true,
		116 => true,
		117 => true,
		118 => true,
		119 => true,
	],

	// Wikibooks @{
	'+wikibooks' => [ 0 => 1, 8 => 0 ],
	// @}

The current output as generated in production:

Production output (corrupt)
"wgNamespacesWithSubpages": {
    "0": 1,
    "8": 0,
    "9": 1,  << Where did you come from?
    "10": 0, << Where did you come from?
    "1": true,
    "2": true,
    "3": true,
    "4": true,
    "5": true,
    "7": true,
    "11": true,
    "12": true,
    "13": true,
    "14": true,
    "15": true,
    "16": true,
    "17": true,
    "100": true,
    "101": true,
    "102": true,

Minimal test case
InitialiseSettings.php
	return [

'wgNamespacesWithSubpages' => [
	'default' => [
	],

	'+wikisource' => [ 8 => 'x' ],
],
];
production-frwikisource.json Bad output (composer buildConfigCache)
"wgNamespacesWithSubpages": {
    "8": "x",
    "9": "x" << WAT
},

Event Timeline

Krinkle created this task.Mar 4 2020, 1:45 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 4 2020, 1:45 AM
Krinkle updated the task description. (Show Details)Mar 4 2020, 1:48 AM
Krinkle updated the task description. (Show Details)

Change 576483 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] SiteConfiguration: Optimise getSetting() internals for getAll()

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

Change 576501 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] SiteConfiguration: Add unit test for tag/suffix conflict scenario

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

Change 576501 merged by jenkins-bot:
[mediawiki/core@master] SiteConfiguration: Add unit test for tag/suffix conflict scenario

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

Change 576483 merged by jenkins-bot:
[mediawiki/core@master] SiteConfiguration: Optimise getSetting() internals for getAll()

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

Change 576862 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@wmf/1.35.0-wmf.22] SiteConfiguration: Add unit test for tag/suffix conflict scenario

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

Change 576864 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@wmf/1.35.0-wmf.22] SiteConfiguration: Optimise getSetting() internals for getAll()

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

Change 576862 merged by jenkins-bot:
[mediawiki/core@wmf/1.35.0-wmf.22] SiteConfiguration: Add unit test for tag/suffix conflict scenario

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

Change 576864 merged by jenkins-bot:
[mediawiki/core@wmf/1.35.0-wmf.22] SiteConfiguration: Optimise getSetting() internals for getAll()

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

Krinkle closed this task as Resolved.Mar 5 2020, 3:36 AM
Krinkle claimed this task.
Krinkle added a project: Performance-Team.