MediaWiki patch: Hidden pages

InfoDabble > Tech Notes > MediaWiki > MediaWiki patch: Hidden pages
Jump to: navigation, search
This project is still under development.

By Eric Hartwell - latest update July 23, 2007

The MediaWiki Hidden namespaces patch (SourceForge) allows custom namespaces to be hidden from public view, only viewable for users with special permission.

This article discusses implementation details for this site using MediaWiki 1.10.0.

[edit] Installation

  1. Download the patch from SourceForge.
  2. Install this patch using the linux command 'patch', like this: patch -p0 < hidden-1.10.0.patch
  3. Update LocalSettings.php
  4. After patching you should create three new system messages:
    • MediaWiki:RNSlist - with the phrase 'Available Namespaces', or similiar
    • MediaWiki:noaccesstitle - with a fitting title
    • MediaWiki:noaccesstext - with a text explaining why the user can't access this site

Once installed you need to make some changes to your LocalSettings.php-file.

You'll need to define accesskeys / groups of namespaces, which then can be used in $wgGroupPermissions. Groupnames must consist of only letters and numbers, and cannot contain a space or _.

The instructions in the README file are a little unclear, but here's the way it works on this site.[1]

$wgExtraNamespaces = array(100 => "DevNotes", 101 => "DevNotes_Talk", 102 => "Support", 103 => "Support_Talk", 200 => "Client1", 201 => "Client1_Talk"); 
$wgContentNamespaces[] = array(100, 102, 200); 
$wgRestrictedNamespaces = array(100 => "nsInternal", 101 => "nsInternal", 200 => "nsClient1", 201 => "nsClient1"); 
 
$wgGroupPermissions['Internal']['nsDevNotes'] = true; 
$wgGroupPermissions['Internal']['nsClient1'] = true; 
$wgGroupPermissions['Client1']['nsClient1'] = true; 
 
$wgGoToEdit = true;

This does the following:

  • Create the new namespaces DevNotes, Support, and Client1
  • Restrict access to the DevNotes namespace using the nsInternal permission, and to the Client1 namespace using the nsClient1 permission
  • Let members of the Internal user group access namespaces with the nsInternal permission, and the Client1 user group acess namespaces with the nsClient1 permission

Net result:

  • All users can access the new Support namespace
  • Only users in the Internal group can access the DevNotes namespace
  • Only users in the Internal or Client1 groups can access the Client1 namespace


[edit] Bug fixes and workarounds

  1. Odd behaviour, occasional error message: Undefined variable: wgRestrictedNamespaces in includes/Parser.php on line 3091
    • See Bugzilla: [ 1752753 ] Undefined variable: wgRestrictedNamespaces
    • Edit Parser.php and insert global $wgRestrictedNamespaces; at the start of function braceSubstitution( $piece ) around line 2905.
  2. When you try to create a page in a restricted namespace using "Go",
    • Workaround: Add $wgGoToEdit = true; in LocalSettings.php
  3. Entries for the restricted (and default) namespace added to end of sidebar
    • This is in the patch includes/Skin.php, function buildSidebar() around line 1663.
    • For this web I want to completely specify the sidebar in MediaWiki:Sidebar, so simply I reversed the patch for Skin.php.

  1. Patch the source extension to add an "indent" (blockquote) parameter