Page MenuHomePhabricator

Unify how namespace properties are set
Open, Needs TriagePublic

Description

Currently (as of 1.30), Namespaces have properties that determine characteristics such as whether it's a content namespace, which namespaces are searched by default, which namespaces can have sub-pages, etc

But the way those properties/flags are set is inconsistent. For properties such as $wgNamespacesWithSubpages and $wgNamespacesToBeSearchedDefault it is an associative array where the key is the code of the namespace and the value is a boolean. However, some configuration structures added to MW later follow a different approach. For example $wgContentNamespaces is an indexed array of namespace codes whose presence on the array sets the flag.

Unifying the approach by which namespace properties are set has the benefit of making them easier to remember and streamlines the documentation.

Arguably, unifying on the earlier approach, i.e. an array of key/value pairs allows for a modular self-contained method of setting them, especially when defining extra namespaces.

A use case:
For example, I group all global namespace settings and extra namespace definitions in a file Namespaces.conf which I include from LocalSettings.php. In it goes blocks such as:

define("NS_SRC", 148);
define("NS_SRC_TALK", NS_SRC + 1);
        $wgExtraNamespaces[NS_SRC] = "مصدر";
        $wgExtraNamespaces[NS_SRC_TALK] = "نقاش_مصدر";
        $wgNamespacesWithSubpages[NS_SRC] = true;
        $wgNamespacesToBeSearchedDefault[NS_SRC] = true;

This block documents everything about the the NS_SRC namespace, except $wgContentNamespaces which is set centrally in another place.

It would be great to be able to set the property of whether NS_SRC is a content namespace in the same block in the same self-documenting way.

Event Timeline

To clarify, you want to be able to write something like $wgContentNamespaces[ NS_SRC ] = true;? In that case, you should be able to just write $wgContentNamespaces[] = NS_SRC; to add the namespace to the array

To clarify, you want to be able to write something like $wgContentNamespaces[ NS_SRC ] = true;? In that case, you should be able to just write $wgContentNamespaces[] = NS_SRC; to add the namespace to the array

Correct.