Manual:$wgNamespaceProtection

From MediaWiki.org
Jump to: navigation, search
Translate this page; This page contains changes which are not marked for translation.

Other languages:
English • ‎français • ‎日本語 • ‎polski
Namespaces: $wgNamespaceProtection
Which namespaces can be edited by whom?
Introduced in version: 1.10.0 (r19110)
Removed in version: still in use
Allowed values: array of arrays
Default value: $wgNamespaceProtection[NS_MEDIAWIKI] = array( 'editinterface' ); (1.10 - 1.13)

$wgNamespaceProtection = array(); (since 1.14)

Other settings: Alphabetical | By function

Details[edit]

This setting allows a wiki to require special permissions to edit some namespaces. By default, the only restriction is that the MediaWiki namespace can only be edited by users with the 'editinterfaceManual:User rights' permission (by default: sysops).

The keys of the array are namespace numbers, and the values are simple arrays of permission names. If you list more than one permission for a given namespace, a user must have all of them to edit pages in that namespace.

Since 1.14, the MediaWiki: namespace is unconditionally protected to users with 'editinterface' right (same as in previous versions). This is set in Setup.phpManual:Setup.php and cannot be modified in LocalSettings.phpManual:LocalSettings.php since otherwise it's too easy to set it incorrectly and leave the wiki insecure. If you want to allow other groups than sysops to edit the MediaWiki: namespace, then grant the 'editinterface' right to those groups.

It's not possible to restrict read access to a certain namespace with $wgNamespaceProtection. (See Extension:LockdownExtension:Lockdown)

Example[edit]

Restricting editing of the main namespace[edit]

$wgNamespaceProtection[NS_MAIN]      = array( 'edit-main' );

This restricts editing in the main namespace to people in a group that has the edit-main permission.

Setting up custom namespaces with restricted write access[edit]

define("NS_OFFICIAL", 100);
define("NS_OFFICIAL_TALK", 101);

$wgExtraNamespaces = 
    array(NS_OFFICIAL => "Official",
          NS_OFFICIAL_TALK => "Official_talk",
    );

$wgNamespaceProtection[NS_OFFICIAL]      = array( 'official-edit' );
$wgNamespaceProtection[NS_OFFICIAL_TALK] = array( 'official-talk-edit' );

$wgGroupPermissions['managers']['official-edit'] = true; // only managers can edit pages in the Official namespace
$wgGroupPermissions['employees']['official-talk-edit'] = true; // employees can edit pages in the Official_talk namespace
$wgGroupPermissions['managers']['official-talk-edit'] = true; // so can managers

Disabling talk pages[edit]

Since "everyone" is not a core permission, literally everyone get's denied access (including sysops). Note that you'll still need to remove the tab through other methods (see: Manual:FAQ#How_do_I_add.2Fremove_tabs_throughout_my_wiki.3FManual:FAQ#How_do_I_add.2Fremove_tabs_throughout_my_wiki.3F)

# Disable all core TALK namespaces
$wgNamespaceProtection[NS_TALK] = ['everyone'];
$wgNamespaceProtection[NS_USER_TALK] = ['everyone'];
$wgNamespaceProtection[NS_PROJECT_TALK] = ['everyone'];
$wgNamespaceProtection[NS_FILE_TALK] = ['everyone'];
$wgNamespaceProtection[NS_MEDIAWIKI_TALK] = ['everyone'];
$wgNamespaceProtection[NS_TEMPLATE_TALK] = ['everyone'];
$wgNamespaceProtection[NS_HELP_TALK] = ['everyone'];
$wgNamespaceProtection[NS_CATEGORY_TALK] = ['everyone'];

See also[edit]