Page MenuHomePhabricator

Impossible to override an array-valued global created by extension registration
Closed, DuplicatePublic

Description

I've created a new global config variable in my extension,

....
        "config": {
                "OresModels": [
                        "damaging",
                        "goodfaith",
                        "reverted",
                        "wp10"
                ],

It doesn't seem to be possible to override that global from LocalSettings.php, because the array value I attempt to override with is array_merge'd into the default array.

Maybe this isn't a bug, I haven't RFM for this yet.

Details

Related Changes in Gerrit:

Event Timeline

awight raised the priority of this task from to Needs Triage.
awight updated the task description. (Show Details)
awight subscribed.
awight renamed this task from Impossible to override an array-valued global create by extension registration? to Impossible to override an array-valued global created by extension registration?.Dec 14 2015, 8:30 AM
awight set Security to None.
awight added a subscriber: Legoktm.

I recommend that people use assoc arrays with boolean values like:

{
	"config": {
		"setting": {
			"Foo": true,
			"Bar": true,
			"Baz": true
		}
	}
}

So removing a value can be done by setting it to false.

With list arrays, it's impossible to figure out whether the configuration says $wgFoo = array( 'bar' ); or $wgFoo[] = 'bar', since the defaults are applied *after* LocalSettings.php is read, so for now it assumes the latter.

Legoktm renamed this task from Impossible to override an array-valued global created by extension registration? to Impossible to override an array-valued global created by extension registration.Dec 30 2015, 1:35 AM

Could they use array_merge.

"_merge_strategy": "array_merge"

Change 263177 had a related patch set uploaded (by Paladox):
Fix when no merge strategy is used

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

We have this problem as well at the permanentfuturelab.wiki , especially with the Visual Editor extension in combination with the foreground skin. Our Wiki hoster Miraheze tried to fix this with the provided patch, but this brought a new problem, the Visual Editor didn't show well in the vector theme (some buttons disappeared).

Change 263177 abandoned by Paladox:
Fix when no merge strategy is used

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

EddieGP subscribed.

Discussed again in T142663, the preferred solution is not not use flat arrays, but assoc ones instead.