NamespaceManager 2.0 manages custom MediaWiki namespaces from a database-backed Codex interface. It supports MediaWiki 1.43 and newer.
- Clone this repository into
extensions/NamespaceManager. - Add
wfLoadExtension( 'NamespaceManager' );toLocalSettings.php. - Run
php maintenance/run.php update. - Visit
Special:ManageNamespacesas a user with themanagenamespacesright. The right is granted tosysopby default.
The update creates namespacemanager_namespace through MediaWiki's abstract
schema system on MySQL, PostgreSQL, or SQLite.
Version 2.0 no longer reads namespace definitions from JSON during requests.
After installing the new version and running update.php, import the old file:
php extensions/NamespaceManager/maintenance/convertNamespaceJson.phpThe script uses the former NamespaceManagerDataPath setting by default,
including $1 database-name substitution. Use --file to select another file:
php extensions/NamespaceManager/maintenance/convertNamespaceJson.php \
--file=/path/to/namespaces.jsonThe script refuses to modify a non-empty table unless --replace is supplied.
Validate a file without writing it by adding --dry-run.
The conversion script and Action API retain the 1.x JSON definition shape:
[
{
"id": 3000,
"name": "Property",
"content": true,
"visualeditor": false,
"searchdefault": true,
"talksearchdefault": false,
"subpages": false,
"talksubpages": true,
"includable": true,
"talkincludable": false,
"aliases": [ "Properties" ],
"talkaliases": [ "Properties talk" ],
"editpermissions": [],
"talkeditpermissions": [ "propertymanagers" ]
}
]id must be an unused even number from 3000 through 4998. name is required.
talkname is optional and defaults to the subject name followed by _talk.
Boolean fields default to false, except includable and talkincludable,
which default to true. Array fields default to empty arrays.
Each subject namespace occupies one typed database row. Alias and permission lists are JSON-encoded within that row. The database is the sole runtime source of truth.
Definitions are memoized within the request and cached through
WANObjectCache, including process caching, hot refresh, stampede protection,
and a cross-server check key. Saves replace the complete definition set in one
database transaction and invalidate both the check key and cached value.
Primary-database reads are used when regenerating the cache because replica lag
must not temporarily change title interpretation.
Saved definitions apply to subsequent requests.
The namespacemanager action requires the managenamespaces right and POST
requests.
operation=getreturns the ordered definition list.operation=saveaccepts the list as JSON innamespaces, requires a CSRF token, validates the complete list, and atomically replaces all definitions.
The Codex interface uses this API rather than posting directly to the Special Page.
Install development dependencies and run the static checks:
composer install
composer test
npm install
npm testRun extension tests from a MediaWiki checkout:
vendor/bin/phpunit extensions/NamespaceManager/tests/phpunit