Page MenuHomePhabricator

Provide a standardized way of disabling/enabling config on a per page basis.
Open, Needs TriagePublicFeature

Description

Feature summary (what you would like to be able to do and where):
In T357077 the web team identified code that would be of general interest to skins and extensions.

Various extensions and skins, have similar configuration which describes a page.

For example the following Vector configuration describes pages where a max width should apply on the content:

"VectorMaxWidthOptions": {
                        "value": {
                                "exclude": {
                                        "mainpage": false,
                                        "querystring": {
                                                "action": "(history|edit|submit)",
                                                "diff": ".+"
                                        },
                                        "namespaces": [
                                                -1,
                                                14
                                        ]
                                },
                                "include": [
                                        "Special:Preferences"
                                ]
                        },
                        "description": "options for configuring where where max-width should and should not apply. More details can be found in Hooks::shouldDisableMaxWidth PHP documentation."
                },

In a lot of cases, the check is simpler, for example $wgPopupsPageDisabled provides a list of pages that the feature can be disabled on:

"PopupsPageDisabled": {
                        "description": "List of pages that should not show Popups. Includes subpages. These pages are subject to the HTML cache policy of the wiki. A purge on these pages maybe needed to see the effect of this configuration variable. Every excluded page should be defined by a canonical name, eg: Special:Userlogin",
                        "value": [
                                "Special:CreateAccount",
                                "Special:GlobalRenameRequest",
                                "Special:Userlogin",
                                "Special:MergeAccount",
                                "Special:ChangeCredentials",
                                "Special:OAuthListConsumers",
                                "Special:GlobalUserRights",
                                "Special:Notifications",
                                "Special:UserRights",
                                "Special:Upload",
                                "Special:VipsTest",
                                "Special:ApiFeatureUsage",
                                "Special:ExpandTemplates",
                                "Special:GadgetUsage",
                                "Special:GraphSandbox",
                                "Special:TemplateSandbox",
                                "Special:MostLinkedFiles",
                                "Special:Book"
                        ]
                },

Namespaces is probably the most common case we saw. For example FlaggedRevisions is configured per namespace:

"FlaggedRevsNamespaces": {
                      "description": "Allowed namespaces of reviewable pages",
                      "value": [
                              0,
                              6,
                              10
                      ]
              },

It's proposed that we standardize this type of configuration and provide a standard way to define configuration that applies on a page basis.

  • Requirements **
  • We should provide a standard format for arrays defining what pages configuration applies
  • There should be a method extensions can call, that can read this configuration and return a boolean - true or false to whether the patch matches the criteria.
  • There should be a way to validate the configuration using CI, for example to avoid typos.

Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):

Benefits (why should this be implemented?):

  • Skins/Extensions would not need to write bespoke code.
  • Features currently that can only be enabled/disabled on certain namespaces would benefit from more control.

Proof of concept:
This code might look something like this:
https://github.com/wikimedia/mediawiki-skins-shared/blob/master/includes/ConfigHelper.php