Commit graph

9 commits

Author SHA1 Message Date
Timo Tijhof
19dd1a7154 tests: Minor follow-up to MySQLPlatformTest/FileBackendTest php8.1 fixes
Follows I3ea6fb26296f (MySQLPlatformTest):

* Avoid uncertainty and make the code improvable/removable by explaining
  what the suppression is for.

* Remove use of outdated AtEase, which hasn't been used in core tests
  for several months (ref phpcs.xml), and more generally not in new code
  in core or extensions (ref T253461).

Follows I12c17e327628 (FileBackendTest):

* I was going to similarly explain the reason by stating from the linked
  task that it is for preg_match, and I was goingn to move the wholesale
  suppression to just the getMockForAbstractClass() call that constructs
  the FileBackend and thus triggers the issue.

* Instead, I've fixed the constructor to not pass a string there in the first
  place as all non-string values are naturally invalid. Even if there is
  a way to satisfy the regex with a non-string value that casts to a
  valid string, that'd be an invalid value for a FileBackend name as it
  pubicly documented as requiring a string, and internally also stored
  and typed as assumed to be (after validation) a string.

* Change the valid test cases to be more representative of actually
  intended-to-be-valid input, and actually-likely-attempted-but-invalid
  input. The regex permits `[a-zA-Z0-9-_]` yet no numbers, capitals
  or dashes were validated by the test, and no special characters
  rejected by the test.

  This follows If29780653 (c250d07bac) from 2019 which added these test
  cases to improve code coverage without input from any (admitedly,
  non-existent) active maintainers.

Bug: T313663
Change-Id: Ia326e17231a53c7102dcb116817a0c3830c510e4
2022-07-27 18:28:35 -07:00
daniel
cf39a40f16 SettingsBuilder: report warnings
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
2022-07-15 12:24:20 +02:00
daniel
5e928f39e8 Dynamic defaults: fix $wgLocaltimezone being empty
Apparently, $wgLocaltimezone is set to the empty string in many
existing LocalSettings.php file, presumably because the installer
failed to detect the correct time zone.

The new code for handling automatic defaults will only trigger if
$wgLocaltimezone is null, not when it is otherwise empty.

This adds fallback code in strategic places to ensure that the empty
string is handled correctly.

Bug: T305093
Change-Id: I39226466f2bb6a36823ae9032fc62f981eabc64a
2022-07-09 18:59:32 +02:00
Aryeh Gregor
b72b9a8c43 Move dynamic defaults into MainConfigSchema
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
2022-07-07 09:55:48 +10:00
daniel
237bbf089f Turn DefaultSettings.php into a deprecated stub
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
2022-05-17 16:50:56 +02:00
Aryeh Gregor
bc3d4e9bd3 Don't assume LocalSettings exists in unit tests
Because it doesn't necessarily, and in fact CI runs unit tests without a
LocalSettings! Of course, in this case the unit test won't correctly
test that $wgCacheEpoch is overridden by the time LocalSettings was
touched, but not much to do about that.

Bug: T306818
Change-Id: I14fcfb24d61f8b48161dec843372d3c3a0a0bc11
2022-04-25 21:12:49 +03:00
Aryeh Gregor
e0e3e81c87 Finish testing dynamic config
Bug: T305093
Change-Id: Iebd58d91a3bba08a59792dcf569e80f2a20322e9
2022-04-24 16:46:55 +03:00
Aryeh Gregor
d16c7f3c90 More dynamic config tests
Change-Id: I2158cfd9d3cddf25dc99cc53c82d83e47c0c0e6b
2022-04-24 15:43:15 +03:00
Aryeh Gregor
7fe63e48c5 Test dynamic configuration logic
To do so, we move the relevant parts to a separate include file that's
included both by Setup and the test.

The --color-moved option is highly recommended when reviewing this patch
to verify correctness.

More tests to come.

Bug: T305093
Change-Id: I931b92357ec48db4665891c8546f86264885e881
2022-04-12 15:21:35 +03:00