Summary
Introduce a standardized and recommended way for re-distributors and packagers of MediaWiki to be able to tune DefaultSettings.php as appropriate.
Full text at https://www.mediawiki.org/wiki/Requests_for_comment/PlatformSettings.php
Problem
Packagers of MediaWiki often have some customizations to DefaultSettings.php that they want to do.
This is currently done by using an mw-config/overrides file to register a custom LocalSettingsGenerator subclass, so when the installer is run, that needed settings are appended or prepended to the generated LocalSettings.php file.
Because these settings are written into LocalSettings.php, existing installations won't see any changes to these defaults unless they regenerate their LocalSettings.php file (which rarely happens).
Solution 1
The distributor/packager will add an extra PHP file at $IP/includes/PlatformSettings.php. MediaWiki will check, at run-time, if that file exists. If it exists, it would be loaded right after DefaultSettings.php.
For example:
--- a/includes/Setup.php +++ b/includes/Setup.php @@ -52,6 +52,11 @@ // Load default settings require_once "$IP/includes/DefaultSettings.php"; +// Load platform settings if they exist +if ( file_exists( "$IP/includes/PlatformSettings.php" ) ) { + require_once "$IP/includes/PlatformSettings.php"; +} +
Standardisation of this file path would make adding such file in a package, not a violation of the Do not hack core convention.
Solution 2
Standardise the file location includes/PlatformSettings.php as being safe for packagers to add in their distribution. But make the LocalSettings.php file responsible for including it.
For example, a distributor could use a mw-config/overrides file to register a custom LocalSettingsGenerator subclass and make sure something like require '/usr/share/mediawiki/includes/PlatformSettings.php' is prepended to the generated LocalSettings.php file.
Standardisation of this file path would make adding such file in a package, not a violation of the Do not hack core convention.
Compared to Solution 1:
- Benefits:
- Does not require changes to MediaWiki core, since it can be implemented with the existing installer overrides system.
- No overhead of conditional checks.
- Strict inclusion (and failure if expected file does not exist).
- Downsides:
- Once this is implemented, people with existing MediaWiki installs need to add that line to their LocalSettings.php, that's a one time cost, which @Legoktm says is acceptable.