aboutsummaryrefslogtreecommitdiffstats
path: root/includes/Settings
Commit message (Collapse)AuthorAgeFilesLines
* GlobalVarConfig: Avoid slowness of array_key_exists on $GLOBALS in PHP 8.1+James D. Forrester2022-09-191-1/+5
| | | | | | | | | Also make the same change for GlobalConfigBuilder for consistency, though that's not critical path. Bug: T317951 Change-Id: I9b46e7bc25365d01dbc86a9b2288559cb9e2cb8d (cherry picked from commit 47da150a9c7b17cc98758f9752f756f8212dc788)
* SettingsBuilder: report warningsdaniel2022-07-151-0/+60
| | | | | | | | | | | This adds functionality to SettingsBuilder for collecting warnings to be logged later, when the logging mechanism has been set up. This also adds a validation step to update.php that aborts the update if any warnings have been registered in SettingsBuilder, or the settings fail to validate against the settings schema. Change-Id: I387905289fb93591f79b96bf4c6cb5ec692b2aff
* Settings: Remove unstable markers and mark interfaces appropriatelyDerick Alangi2022-07-115-5/+7
| | | | | | | CachedSource is newable and stable to call while the other interfaces are now stable to implement. Change-Id: Ifcb4865691cb7ec308acac2bd3f367b14424a0e1
* Move dynamic defaults into MainConfigSchemaAryeh Gregor2022-07-079-11/+270
| | | | | | | | | | | | | | | | | | | | | | | | | The goal is to keep the actual default values for settings in the same place as the setting is declared, and applied using the regular means for loading the settings -- not in a separate piece of code that needs to be loaded through some entirely different mechanism. SetupDynamicConfig.php now contains a few categories of things: * Post-processing of configuration settings, where already-set settings are altered. This could be moved to MainConfigSchema too as a separate set of methods. * Processing of old aliases of settings (blacklist, slave) that are not registered as settings anymore and therefore are not available to MainConfigSchema. This could perhaps be moved to LocalSettings processing somehow? * Setting $wgUseEnotif, which is also not registered as a setting. Easiest would be just to declare it as a setting and have it set unconditionally. * Setting the actual timezone to $wgLocaltimezone. This is not related to configuration and should just be in Setup.php. Bug: T305093 Change-Id: Ia5c23b52dbbfcb3d07ffcf5d3b7f2d7befba2a26
* Remove 'ignoreKeys' from config schemaLucas Werkmeister2022-07-061-7/+0
| | | | | | | Unused since change I88754b52c2 (commit 9e95539fc9) – this was only used for SessionProviders, which is now a map/object instead. Change-Id: I8da686e6379eb33a63799874fb44f9b0030ab5ba
* Merge "Support etcd as a source for SettingsLoader"jenkins-bot2022-06-301-0/+286
|\
| * Support etcd as a source for SettingsLoaderDan Duvall2022-06-211-0/+286
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added a EtcdSource to handle loading of settings from etcd. The implementation is based on EtcdConfig but is much simpler due to the reliance on the existing source caching layer. GuzzleHttp\Client is used over MultiHttpClient as the latter depends on MediaWikiServices and therefore should not be used during early initialization. A naive cache key is based on the etcd request URL, effectively representing the etcd API version and settings directory, and uses either the DNS SRV entry as the host name or the host name itself if discovery is disabled. The cache TTL is set to 10 seconds. The combination of this low TTL and the naive key should replicate the current caching pattern of EtcdConfig. Stale results are allowed for failover in case of temporary unavailability. At this time, the expiry weight was not changed from the suggested 1.0. However, verification of this as a suitable early expiration coefficient should be performed in a production like environment. Bug: T296771 Change-Id: I782f4ee567a986fd23df1a84aec629e648a29066
* | Add support for nested property schemas in MainConfigSchema.daniel2022-06-295-140/+171
|/ | | | | | | | | | | | This adds support for JSONSchema style property declarations with nested schemas. This is a step towards using more nested structured for configuration, rather than adding to the over 700 keys already defined in the main config schema. Defaults from property schemas are aggregated into a default value in the top level schema. Descriptions are however not yet aggregated. Change-Id: Iaf46a9ecc83bee3566098c56137a1be66bff2ab9
* Docs: remove references to DefaultSettings.phpdaniel2022-05-301-2/+2
| | | | | Bug: T300129 Change-Id: I1e83a0dde6235bed91d28d7d43691c6a5d979f2f
* Merge "Settings: Add remaining schema info to config-schema.php"jenkins-bot2022-05-181-17/+42
|\
| * Settings: Add remaining schema info to config-schema.phpdaniel2022-05-171-17/+42
| | | | | | | | | | | | | | | | | | | | | | | | By optimizing the structure of config-schema.php for fast loading, some information needed for schema validation was lost. This patch ensures that all schema information is retained in config-schema.php. The code for consuming this field already existed, as written for what we already output to the generated config.schema.yaml file. Bug: T307769 Change-Id: I8adcdfd2b8fb5f5b96308eea74c07d8cc7a4d6ba
* | Turn DefaultSettings.php into a deprecated stubdaniel2022-05-173-4/+87
|/ | | | | | | | | | | DefaultSettings.php has been replaced by MainConfigSchema. Loading DefaultSettings.php is deprecated. Code that needs to have access to configuration defaults should use the ConfigSchema service object. Bug: T300129 Change-Id: I7b2c0ca95a78990be1cdb9dd9ace92f6dcf1af15
* Merge "Config builder optimisations (combined)"jenkins-bot2022-05-097-32/+155
|\
| * Config builder optimisations (combined)Tim Starling2022-05-067-32/+155
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a modified rebase of a patch by Tim, see I75f405930a7b14561389c59d147640e870146bec. Some benchmark results (from my laptop): Loading defaults from config-schema.php: - Master: 115/sec ( 8.7ms) - I75f4059: (Tim): 575/sec ( 1.7ms) - Id9dd0bf: (Daniel): 1120/sec ( 0.9ms) - This (Tim+Daniel): 1420/sec ( 0.7ms) Loading defaults and merging settings (worst case): - Master: 80/sec (12.4ms) - I75f4059: (Tim): 93/sec (10.8ms) - Id9dd0bf: (Daniel): 200/sec ( 4.9ms) - This (Tim+Daniel): 682/sec ( 1.5ms) Original commit message by Tim: * Explicitly import function array_key_exists to activate the special opcode * Batch creation of MergeStrategy objects * Batch default assignment to ArrayConfigBuilder The batches mostly help by allowing more inlining, eliminating some function calls. Reduced time for apply/finalize benchmark from 540µs to 170µs. Co-Authored-By: Tim Starling <tstarling@wikimedia.org> Change-Id: I3d4dd685eaaa4351801b3bac6ce1592eea925c5f
* | Merge "Add tests for ConfigBuilderBase"jenkins-bot2022-05-091-1/+1
|\ \ | |/ |/|
| * Add tests for ConfigBuilderBasedaniel2022-05-051-1/+1
| | | | | | | | | | | | | | | | This adds tests for the abstract base class, to make sure the generic implementation matches the contracts. Tests for existing subclasses may not be using the generic code, and new subclasses may run into trouble. Change-Id: I2c652c3028862ad52dbd0edaa454bec953e94506
* | Use inverted schema definition for fast loading.daniel2022-05-062-53/+215
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we pre-generate the data structure for holding schemas in a way that is optimized for the way we typically access this information we can save time on initialization: Instead of having the schema for a given setting in one array with keys for the default, type, etc, this puts all defaults into one array, all types into another array, etc. This allows the default values to be copied in bulk, without having to iterate over the 700+ settings and look for a default value in each schema array. Benchmark results from my laptop: 0.85ms for loading config-schema.php, that is a 85% improvement over the 6.3ms it took before. It's even 32% faster than loading DefaultSettings.php, which takes 1.26ms. Bug: T300129 Change-Id: Id9dd0bff6a6d4b501e74237b5d7198088c38c302
* | Merge "ConfigBuilder: introduce setMulti() for bulk updates"jenkins-bot2022-05-065-17/+41
|\ \
| * | ConfigBuilder: introduce setMulti() for bulk updatesdaniel2022-05-055-17/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | When no merge strategies are needed, config values can be set in bulk. This patch only uses it for config-overrides, but it is intended to be used for config-schema in a follow-up. Change-Id: Ic7e62513ad5227887f8a83bb8b757b5667643989
* | | Merge "WikiFarm: remove site detection based on domain name."jenkins-bot2022-05-051-45/+20
|\ \ \ | |/ / |/| |
| * | WikiFarm: remove site detection based on domain name.daniel2022-05-041-45/+20
| |/ | | | | | | | | | | | | | | | | | | While detecting the site name based on the request domain is common, the exact mappings used in practice differ a lot. If we implemented one, we could never change it. It seems beter to require the requested site to be identified explicitly. Bug: T221535 Change-Id: I31c20e87bb7d5fc4565714e86f547b42bacea82f
* / Settings: Skip merging logic for defaults when possibledaniel2022-05-051-10/+59
|/ | | | | | | | | | | | When loading defaults from config-schema (previously known as DefaultSettings), we can just blindly set the values, as no overrides have been applied yet at this point (e.g. from LocalSettings.php), and thus no need for backward merging. We only need to apply backwards merging of defaults for config variables that may have actually already at the time that the default is loaded. Change-Id: I415f865a77c091b75a2ce38da02d1dfbd7ead106
* SettingsBuilder: remove @unstable markers.daniel2022-05-036-18/+22
| | | | | | | The @unstable markers were intended for the 1.38 release. The interface can be conisdered stable in 1.39. Change-Id: Ie2fdd5bfe2622aa8845883019c1666dfb3073719
* Use MainConfigNames instead of string literals, #4Aryeh Gregor2022-04-261-4/+5
| | | | | | | | | | | | | | | | | | | | | Now largely automated: VARS=$(grep -o "'[A-Za-z0-9_]*'" includes/MainConfigNames.php | \ tr "\n" '|' | sed "s/|$/\n/;s/'//g") sed -i -E "s/'($VARS)'/MainConfigNames::\1/g" \ $(grep -ERIl "'($VARS)'" includes/) Then git add -p with lots of error-prone manual checking. Then semi-manually add all the necessary "use" lines: vim $(grep -L 'use MediaWiki\\MainConfigNames;' \ $(git diff --cached --name-only --diff-filter=M HEAD^)) I didn't bother fixing lines that were over 100 characters unless they were over 120 and triggered phpcs. Bug: T305805 Change-Id: I74e0ab511abecb276717ad4276a124760a268147
* Merge "Use MainConfigNames instead of string literals, #2"jenkins-bot2022-04-131-4/+5
|\
| * Use MainConfigNames instead of string literals, #2Aryeh Gregor2022-04-131-4/+5
| | | | | | | | | | | | | | This covers all occurrences of /onfig->.*get( '/ in includes/. Undoubtedly there are still plenty more to go. Change-Id: I33196c4153437778496f40436bcde399638ac361
* | Merge "Fix WikiFarmSettingsLoaderTest failure if MW_WIKI_NAME is defined"jenkins-bot2022-04-131-2/+12
|\ \ | |/ |/|
| * Fix WikiFarmSettingsLoaderTest failure if MW_WIKI_NAME is definedTim Starling2022-04-081-2/+12
| | | | | | | | | | | | | | The WikiFarmSiteDetector config variable is ignored when MW_WIKI_NAME is defined. Change-Id: I88f72a693f901671f31e9d3acc7abd253f98c0cf
* | Trigger an error instead of throwing on unapplied php_ini settingsIsabelle Hurbain-Palatin2022-04-081-2/+5
|/ | | | | | | | | We do not necessarily want the setting of php_ini values to throw when they cannot be set as this can interact with maintenance scripts run with xdebug. trigger_error still reports the information, but does not interrupt the execution altogether. Change-Id: I32f093e7d1ef3eccf413ccbb3e96520815523028
* Merge "Make MainConfigSchema more readable."jenkins-bot2022-04-072-4/+143
|\
| * Make MainConfigSchema more readable.daniel2022-04-072-4/+143
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows for PHPDoc-style types to be used in MainConfigSchema, and adds aliases for the 'object' and 'array' types, to avoid confusion. The type 'map' can now be used for associative arrays, it will be represented as 'object' in JSON Schema. Similarly, 'list' can be used to refer to sequential arrays, it will be represented as 'array' in JSON schema. In addition, the basic PHP types are mapped to their JSON counterparts, including support for nullable types. For example: "?map" will become [ "object", "null" ]; "float|false" will become [ "number", "boolean" ]; Change-Id: I89617d06afd1e97ee1bc9bc49b6c77bed7bd50d9
* | Merge "Update @since tags of config schema code"jenkins-bot2022-04-061-1/+1
|\ \
| * | Update @since tags of config schema codeAlexander Vorwerk2022-04-021-1/+1
| |/ | | | | | | | | | | | | Did not make it into 1.38 Follow-Up: I663c08b8a200644cbe7e5f65c20f1592a4f3974d Change-Id: Ib981b4511384a4102a3128de866ddca6ff3fe14b
* | Merge "Benchmark script for settings loading."jenkins-bot2022-04-041-0/+21
|\ \ | |/ |/|
| * Benchmark script for settings loading.daniel2022-03-311-0/+21
| | | | | | | | Change-Id: I323a3469c574b55ad78abb35863f30b1007f3135
* | Add wiki-farm supportdaniel2022-04-012-0/+123
| | | | | | | | | | | | | | | | | | | | | | | | Added support for an easy to configure multi-tenant ("wiki farm") mode: Settings for each site can be placed in a directory specified by $wgWikiFarmSettingsDirectory. Site detection is controlled by $wgWikiFarmSiteDetector and defaults to the requested host name. Instructions for manual testing: https://etherpad.wikimedia.org/p/T221535 Bug: T221535 Change-Id: I7581921b7d99ba1fe7e25523fde691d76b67a99c
* | phan: Remove PhanPossiblyUndeclaredVariable suppressionUmherirrender2022-03-301-1/+1
|/ | | | | | | | | Make phan stricter about conditional variable declaration Remaining false positive issues are suppressed. The suppression and the setting change can only be done together Bug: T259172 Change-Id: I1f200ac37df7448453688bf464a8250c97313e5d
* Allow LocalSettings.php to be loaded in function scope.daniel2022-03-282-0/+94
| | | | | | | | | | | | | | This adds an experimental mode that loads LocalSettings.php in a function, rather than in top level global scope. This is controlled using the MW_USE_LOCAL_SETTINGS_LOADER environment variable. This is not intended for use in production as this time. The experimental mode should be available in the 1.38 release, so people can try it out with different setups. Bug: T304183 Depends-On: Ie6245ff8cd2bc7bab2af3b1450070185dbc2d824 Change-Id: I0f20024803336064ecb07b51fa56581af7b67a85
* SettingsBuilder: add comments about batched caching.daniel2022-03-231-0/+3
| | | | | | | | | | | | One reason to have batching in SettingsBuilder is so we can cache an entire batch of settings after merging them, rather than caching each file individually. However, this has not been implemented, and it's not entirely clear if it's a good idea. This patch adds comments to SettingsBuilder that point to the relevant ticket, for reference and consideration when working on SettingsBuilder in the future. Bug: T304493 Change-Id: I1fb7b7e4a97e6d0788c9b1732a1718f3c8b365d5
* phan: Disable null_casts_as_any_type settingUmherirrender2022-03-212-0/+2
| | | | | | | | | | | Make phan stricter about null types by setting null_casts_as_any_type to false (the default in mediawiki-phan-config) Remaining false positive issues are suppressed. The suppression and the setting change can only be done together Bug: T242536 Bug: T301991 Change-Id: I0f295382b96fb3be8037a01c10487d9d591e7e01
* phan: Disable scalar_implicit_cast settingUmherirrender2022-03-181-0/+1
| | | | | | | | | Make phan stricter about scalar types by setting scalar_implicit_cast to false (the default in mediawiki-phan-config) Bug: T242536 Bug: T301991 Change-Id: Ia2fe30b17804186571722e728578121c8b75d455
* Use class constants to define config schema, rather than config-schema.yamldaniel2022-03-171-0/+97
| | | | | | | | | | | | | | | | Instead of maintaining the config schema as a yaml file, we maintain it as a set of constants in a class. From the information in these constants, we can generate a JSON schema (yaml) file, and an php file containing optimized arrays for fast loading. Advantages: - PHP doc available to IDEs. The generated markdown file is no longer needed. - Can use PHP constants when defining default values. NOTE: needs backport to 1.38 Change-Id: I663c08b8a200644cbe7e5f65c20f1592a4f3974d
* Fix edge cases in schema validation.daniel2022-03-082-26/+113
| | | | | | | | | | | | | | | | | | | | | | | | | | Since PHP arrays make no clear distinction between lists (JSON arrays) and maps (JSON objects), some edge case handling is needed to make validation work reliably when we declare types for all arrays: 1) Allow array keys to be ignored, so an associative PHP array validates as a JSON array. This is needed for the SessionProviders setting. 2) Allow associative arrays with numeric keys to validate as JSON objects. This is done by ignoring the type validation when numeric keys are detected. A warning is returned in the status object. 3) Work around validation failing on float values that are expected to be integers. All numbers come from the yaml parser as floats, and the "integer" type in JSON schema should accept floats with if the fractional part is 0. But that doesn't seem to work, we need to cast the values to integers explicitly. Also, this fixes some mistakes in the schema: LockManagers is a list, so it should use the JSON type "array". NamespacesToBeSearchedDefault is a map (JSON object), even though it uses numeric keys. The Actions registry is also a map. Change-Id: I9d0453d740c377b7cce574df743536c39a0ec619
* Fix various documentation related to null typesUmherirrender2022-02-261-1/+1
| | | | | | | | The functions returning null or the class property is set explict null Found by phan strict checks Change-Id: I4a271093fb6526564d8083a08249c64cb21f2453
* config-schema: Define types for all arrays.daniel2022-02-236-84/+108
| | | | | | | | | | | | | | | | | | This patch ensures that we know which arrays are lists (JsonSchema type "array") and which are maps (JsonSchema type "object"). We can then default to array_merge for lists and to array_plus for maps. This seems clearer than requiring an explicit merge strategy to be declared for all arrays. This patch specified a mergeTrategy for some config variables that need behavior different from the default. This patch also changes the merging behavior to allow non-array values to replace arrays and vice versa. It also changes the behavior of defaults to allow falsy values to override non-falsy defaults. Bug: T300129 Change-Id: Ia7b0c0250af6a957eac1efb554fb47511f5e093f
* Merge "Avoid references to DefaultSettings."jenkins-bot2022-02-221-2/+3
|\
| * Avoid references to DefaultSettings.daniel2022-02-221-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This replaces references to DefaultSettings with references to config-schema.yaml where appropriate. NOTE: this does not yet change Setup.php. DefaultSettings.php remains intact and is still being used. NOTE: this does not remove usages in the installer, see I5d8843a1062fbf for that. Bug: T300129 Change-Id: Ie6152cf510c3be61bc22167ca6d90dfc28910a45
* | Allow config merge strategies to be bypassed.daniel2022-02-221-14/+69
|/ | | | | | | | | | Sometimes, we need to force an exact value and bypass the default behavior of merging config variables. This also renames setConfigValue to putConfigValue, to avoid confusion about the behavior of that method. Change-Id: I82c606632b94f974e655a44a0b63394de7a0804b
* Introduce IterableConfigdaniel2022-02-141-1/+3
| | | | | Bug: T301544 Change-Id: I0a93ebb5305f95cf1b12df276f25a44195fedafa
* Use a mutex to prevent settings cache stampedesDan Duvall2022-01-281-29/+82
| | | | | | | | | | | | | | | | There are cases where probabilistic early expiry is not enough to prevent cache stampedes, most notably during a cold start/restart where the cache is not yet populated and during conditions where source I/O wait times may exceed the possible range of early expiry offset. To completely prevent cache stampedes from occurring, a mutex must be used around settings (re)caching. Early expiry is left in place as it should still be quite effective in reducing cache lock contention. Bug: T296771 Change-Id: I99676466ce1ad4f1622867158d2ed15ef9202ec2