Page MenuHomePhabricator

Default configuration parameter settings get merged with new settings
Open, Needs TriagePublic

Description

What I want to do is define these three settings by defining a new array for the configuration parameter:

$wgHostStatsCommands = [
	'df -H',
	'lsb_release -d',
	'date'
	];

What happens is that also the default settings are considered, i.e. in the end 'hostname', 'df-h', 'df -H', 'lsb_release -d', 'date' are shown instead of just 'df -H', 'lsb_release -d', 'date' as desired. This started after the conversion to the extension registration system. Apparently I have no clue how to fix the extension.json file, i.e. how to disable any existing merge strategy to "config".

Event Timeline

@Legoktm You might be able to help here. The docu about merge strategies does not provide a clue. Perhaps this is even the wrong spot to look how to fix this.

If we change extension.json to:

	"config": {
		"HostStatsCommands": {
			"value": {
				"hostname": true,
				"df -h": true
			}
		}
	},

Then in LocalSettings, we can do:

$wgHostStatsCommands = [
	'hostname' => false,
	'df -h' => false,
	'df -H' => true,
	'lsb_release -d' => true,
	'date' => true,
];

And in the code, use array_filter( $wgHostStatsCommands ).

The problem with list style arrays is that it's hard/mostly impossible to determine whether the configuration in LocalSettings.php is trying to append to the default list or overwrite it entirely. But the => true / => false thing gets around that.

Change 516958 had a related patch set uploaded (by Kghbln; owner: Kghbln):
[mediawiki/extensions/HostStats@master] Release version 2.0.0

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

@Legoktm Thanks a lot for your explanation and advice!!! I authored a new version since this is breaking.

Change 516958 abandoned by Kghbln:
Release version 2.0.0

Reason:
Second thoughts: This is getting too complicated also for admins. Thus abandoing for another approach.

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

Now coming with https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/HostStats/+/519399/. I just removed the initial settings for everyone to choose whatever they like from the start. Moreover a less breaking thus preferable approach.