Page MenuHomePhabricator

Allow namespace IDs defined in extension.json to be overwritten in LocalSettings.php
Closed, ResolvedPublic

Description

Extensions can specify namespace IDs in extension.json, see https://www.mediawiki.org/wiki/Manual:Extension.json/Schema#namespaces. These IDs however do not just act as defaults. They cannot be overwritten. That means that it is not possible to install an extension that has a namespace in extension.json that is already used on the wiki.

Instead, the ID given in extension.json should act as a default. Overriding it in LocalSettings.php by setting an entry in $wgNamespaces should be possible.

Event Timeline

Legoktm subscribed.

I'm fairly sure this is a duplicate but I can't find the other task right now.

Anyways, my plan at that time was to see if the constant was already defined, and then use its value and not redefine it. That allows you to continue using the constant in the code correctly without needing to check if it was override. That's also the pattern many extensions already use:

if ( !defined( 'NS_FOO' ) ) {
	define( 'NS_FOO', 2 );
	define( 'NS_FOO_TALK', 3 );
}
WMDE-leszek renamed this task from Allow namespace IDs defined in extension.js to be overwritten in LocalSettings.php to Allow namespace IDs defined in extension.json to be overwritten in LocalSettings.php.Mar 16 2017, 8:34 AM
WMDE-leszek triaged this task as Medium priority.

I already made a patch for this: https://gerrit.wikimedia.org/r/#/c/342879/ but gerrit-bot seems to be broken or it just hates me.

Moving to "Monitoring" on Wikidata Sprint board, as this is not actively work on at the moment.

Change 353097 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] Allow namespaces defined in extension.json to be overwritten locally.

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

Change 342879 abandoned by Ladsgroup:
Let extension extra namespace ids gets overridden by LocalSettings.php

Reason:
In favor of If648d6e218847e6632

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

Change 353097 merged by jenkins-bot:
[mediawiki/core@master] Allow namespaces defined in extension.json to be overwritten locally.

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

Are there any chances that change "If648d6e218847e6632d643ea724cd3da3945db70" gets backported to REL1_27 LTS?

patch merged, fixed on master, targeting 1.30 release.

Are there any chances that change "If648d6e218847e6632d643ea724cd3da3945db70" gets backported to REL1_27 LTS?

I guess that depends on whether you consider this a feature or a bug fix...

The patch is pretty self-contained, try to apply it manually.

Change 364658 had a related patch set uploaded (by Robert Vogel; owner: Daniel Kinzler):
[mediawiki/core@REL1_27] Allow namespaces defined in extension.json to be overwritten locally.

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

Change 364660 had a related patch set uploaded (by Robert Vogel; owner: Daniel Kinzler):
[mediawiki/core@REL1_28] Allow namespaces defined in extension.json to be overwritten locally.

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

Five day ago https://gerrit.wikimedia.org/r/#/c/325081/ got merged and thus introducing a merge conflict to my backport. Fortunately by this it got possible to cherry-pick the original change to REL1_27, which I did. I also cherry-picked to REL1_28 as this is the current stable. I abandoned my backport.

Change 364658 merged by jenkins-bot:
[mediawiki/core@REL1_27] Allow namespaces defined in extension.json to be overwritten locally.

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

Change 364660 merged by jenkins-bot:
[mediawiki/core@REL1_28] Allow namespaces defined in extension.json to be overwritten locally.

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