User:Skizzerz/Namespaces

Preliminary notes edit

Notes to myself for the upcoming Special:Namespaces (see MediaWiki roadmap). I'm planning on including most of the necessary schema changes for this as part of the configuration database RFC. Should that be accepted, another RFC will be created to further discuss the other changes detailed below.

  • Will meet all of the specifications set out in Extension:Namespace manager (page detailing the special page as it exists in the outdated wikidata branch)
  • Support all current namespace configuration variables
  • Use a table in the database to hold these namespaces and their configuration, then parse them out on startup (before LocalSettings)
  • Start numbering custom namespaces at 300 so it doesn't conflict with extension-added namespaces
    • Register constants NS_* to correspond with the numbers
  • Improved UI
  • Allow deletion of namespaces with pages in it for those with the merge_pseudonamespaces right
    • This will automatically reassign all pages in that namespace to the main namespace, then delete that namespace
    • System namespaces still cannot be deleted
    • This will re-add the prefix to the page name and reassign the namespace to the main namespace
    • Reversible by re-creating the namespace (all the pages will be merged back in)
  • Allow adding new namespaces which conflict with existing pseudonamespaces for those with the merge_pseudonamespaces right
    • This will automatically strip the prefix from the page name and add in the correct namespace number
    • Reversible by deleting the new namespace (all the pages will be merged into the mainspace with proper prefix)
  • Pseudonamespace converter will automatically convert discussion pages into the appropriate talk namespace -- no checkbox option
  • Default link prefix detection should only detect actual namespaces, interwiki prefixes, or interlanguage prefixes. Pseudonamespace prefixes will still be prepended by the default link prefix
    • Related, but not really part of this feature per se: {{DEFAULTPREFIX:}} parser function to set a default link prefix on a per-page basis to override the namespace setting.
  • Talk namespace detection, either:
    • Hide discussion tab if respective talk namespace does not exist, or
    • Force creation of talk namespace

Planning edit

New database schema edit

  • New namespace table needed to hold namespace relational data
  • Cannot guarantee that a talk namespace number will directly follow the namespace it is tied to, so this change needs to be reflected in code.
Schema for namespace table
Field Type Extra Notes
ns_id int NOT NULL PRIMARY KEY
  • Namespace id, tied to NS_* constant.
  • Cannot autoincrement due to negative namespace numbers
ns_constant varchar(32) NOT NULL
  • NS_* constant name.
    • Talk namespaces will have this autopopulated upon creation based on the ns it is tied to.
    • Non-talk namespaces will be based on the name passed in as the namespace name.
      • If this name does not create a valid constant name (due to foreign characters, etc.), then assign NS_id as the constant (e.g. NS_300 or NS_301)
ns_protection blob NOT NULL DEFAULT ""
  • $wgNamespaceProtection settings, in semi-CSV format
  • Format is "restriction:permission1,permission2;restriction:permission3,..."
    • Where restriction is a permission like "edit" or "read" (only "edit" will be supported as of first release)
    • Where permission is a permission that can be assigned via $wgGroupPermissions
  • MediaWiki namespace is unconditionally protected to "edit:editinterface", but put it in the db anyway to make that restriction more transparent.
ns_system tinyint NOT NULL DEFAULT 0
  • Is this a system namespace (such as Special: or (Main) or User:)?
  • These have more restrictions placed on them in the Special page UI and cannot be deleted.
  • It is impossible to set this flag via the Special page
ns_special tinyint NOT NULL DEFAULT 0
  • Is this a special namespace (currently only Media: or Special:)?
  • These namespaces don't actually hold pages and thus have many options removed in the Special page UI.
  • These pages should also have ns_system set to 1
  • it is impossible to set this flag via the Special page
ns_options blob NOT NULL DEFAULT ""
ns_talk_of varchar(32) NULL
  • Namespaces this is a talk namespace of
  • NULL if it isn't a talk namespace
  • CSV of namespace ids it is a talk namespace of if it is a talk namespace
  • Hold namespace names in a namespace_l10n table
  • For now just a wrapper for $wgExtraNamespaces and $wgNamespaceAliases (language all)
    • In the future might allow localized names for extra and built in namespaces
Schema for namespace_l10n table
Field Type Extra Notes
nl_namespace int NOT NULL
  • Namespace id this is a name for
nl_name varbinary(255) NOT NULL
  • Name for the namespace
nl_lang varbinary(32) NOT NULL
  • Language the name is present in (or "all" for all languages)
    • Currently only "all" is supported but in the future per-language namespace aliases might be supported, so building support for it now would save headaches later
nl_default tinyint NOT NULL
  • Whether this is the default name for the namespace (1) or a canonical alias (0)
  • Index nl_namespace_name on nl_namespace and nl_name
  • Unique index nl_namespace_default on nl_namespace and nl_default

Special Page edit

  • Shown only to bureaucrats by default, requires 'namespaces' permission.
  • Form determines current namespaces from the namespaces table as well as namespaces added via $wgExtraNamespaces. Default namespaces and those present in wgExtraNamespaces but not in the database are marked as "protected"
    • A "protected" namespace is one that cannot be deleted, the default name cannot be changed, the namespace number cannot be changed, and the namespace constant cannot be changed. Canonical names and other options can still be modified on these namespaces (exception of "special" namespaces, which limit the number of options that can be set)
  • Form displays these namespaces in a table format, with [edit], [delete], etc. links provided to modify a specific namespace
    • We don't want to allow modification of all namespaces at once as that would cause very confusing log entries.

Current Progress/Milestones edit

Legend
[ ] Not done
[+] Partially done
[x] Done
    [ ] Sub-item
        [ ] Sub-sub-item
            [ ] etc.

Milestone 1 (pre-alpha) edit

Upon completion of this milestone, the current progress so far will be committed to the special-namespaces branch of SVN. Until that point, code will be available upon request to my talk page. This milestone will feature the following:

  • Default namespaces are stored in the database instead of DefaultSettings.php
  • Custom extra namespaces defined in settings files will still work
  • Namespace variables defined in settings files will still work ($wgNamespacesWithSubpages, etc.)
  • No Special:Namespaces yet
[+] Schema (namespace and namespace_l10n tables)
    [x] MySQL
    [x] SQLite
    [ ] Postgres
    [ ] DB2 (?)
    [ ] Oracle (?)
    [x] Work into installer
    [x] Work into updater
    [ ] Populate namespace table with default namespaces
[ ] Maintenance script to restore default namespaces in case they get deleted/corrupted
[ ] Remove default namespace definitions from DefaultSettings.php
[ ] Figure out some way of registering namespaces before LocalSettings.php gets loaded
[ ] Maintain interoperability with $wgExtraNamespaces (for extensions)
[ ] Maintain interoperability with configuration variables that affect namespaces ($wgNamespacesWithSubpages, etc.)

Milestone 2 (alpha) - TENTATIVE edit

Features completed in this milestone will be committed to the SVN branch as they are completed. This milestone will feature the basics described on this page, but nothing fancy quite yet. Features:

  • Special:Namespaces operational for adding/deleting custom namespaces and configuring namespace options for custom and default namespaces
  • Options set in LocalSettings or other config files currently override any options set in the database
  • No pseudonamespace support yet
  • No default link prefixes yet
  • No per-language namespace names yet
  • To be expanded...
[ ] Merge recent changes from trunk to ensure compatibility with existing pre-alpha code
[ ] Special:Namespaces page
[ ] Logging

To be expanded...

Milestone 3 (beta) - TENTATIVE edit

Features completed in this milestone will be committed to the SVN branch as they are completed. Features:

  • Pseudonamespace support
  • Default link prefixes (with DEFAULTPREFIX: parser function)
  • To be expanded...
[ ] Merge recent changes from trunk to ensure compatibility with existing alpha code
[ ] Pseudonamespace support
[ ] Default link prefixes

To be expanded...

Milestone 4 (v1) - TENTATIVE edit

Features completed in this milestone will be committed to the SVN branch as they are completed. Once totally finished, the current code will be merged back into trunk for the 1.17 release. Features:

  • To be expanded...
[ ] Merge recent changes from trunk to ensure compatibility with existing beta code
[ ] Merge into trunk
    [ ] Merge recent changes from trunk first to ensure compatibility with code thus far
    [ ] Merge code thus far back into trunk for 1.17 release

To be expanded...