This is a modified version of Ie282bc5b5f5df0bbd6a40c8362ba73fcbbf36c2e
which was reverted in 5c7cca8776.
Bug: T321969
Change-Id: I566d54a473aa51c4cdaada21a49d63c0624aab93
This shows a warning message when maintenance scripts are run directly.
maintenance/run.php should be used instead.
Change-Id: Ibd47e3f29f93238ccd3e607774927e639ba74ace
Since 9cc1cd3 a filterDeprecation() call exists to hide MediWiki
deprecations, let php deprecation show up
Depends-On: Id07a55743bdfe04022b7c96acb6c154c7fe33098
Change-Id: Ia51b00399c584671ccf5d9fb8dfed1e94e5d60f9
PHPUnit tests will fail to run in the IDE if they access the service
container.
Note that the structure test will not include routes registered by
extensions when run without the phpunit wrapper: data providers are
executed before config is loaded, so extensions do not have a chance to
register.
Change-Id: If9d408456686b408062204bec4b41c95f60ab775
While accessing a SettingsBuilder instance via global state should not
be encouraged, we still need it sometimes. So use a static getter
instead of a global variable. That way, we can emit deprecation warnings
when we have proper alternatives available.
Change-Id: I0013bdab474710fd521532dd2653b3789e2ede34
Usually it doesn't make much of a difference, but potentially can
when the array is big. The extra conversion also makes the code more
complicated, I would argue.
Change-Id: I91b9e82ca801dd64523557d616462b7ea7edc7b0
It appears that autoloading classes via MediaWiki's PSR-4 autoloader has
a not insignificant performance penalty, especially when hundreds of
PSR-4 classes like HookRunner's hook interfaces are autoloaded. Using a
classmap autoloader, like we already do for PSR-4 classes from Composer
dependencies, is a potential way to reduce the performance impact
here.[1]
For core classes, this can be done by simply not excluding PSR-4 classes
in AutoloadGenerator, causing it to include appropriate mappings in the
generated autoload.php classmap. I had to exclude one class_alias()
declared in Result.php from the classmap with a NO_AUTOLOAD stanza,
because including it broke AutoLoaderStructureTest's assertion that all
aliases should be defined in the same file as the aliased class.
Assuming this is still an issue, this would already have been a problem
because the test was previously skipping every PSR-4 class. Excluding
this file via NO_AUTOLOAD just restores that status quo.
----
[1] https://phabricator.wikimedia.org/T274041#8358399
Bug: T274041
Change-Id: I0aa62c944d874bf7a9f3a240e72e58fe6a887b28
Follow-up 3270283abf.
This way the test is only run on commits made to this repo, not on all
skins and extensions, and so saving an awful lot of downloads from
happening in CI unnecessarily.
Bug: T203694
Change-Id: I071be5821711fb8b039ff24293f66a8ff9d70514
Enable the equivalent of running `manageForeignResources.php verify`
as a structure test via PHPUnit.
Related cleanups for this to work well:
* Improve cache key readability before enabling in CI.
* Document how we do caching in CI.
* Change some exceptions to errors so that we don't
stop on the first error, thus improving the usefulness of the CI
result by telling the developer all mismatches instead of only
the first.
* Fix incorrect typehint for nullable $integrity.
Bug: T203694
Change-Id: I8aeffc1f2e81ffcf037977528f94c00995791999
This allows config variables to be declared obsolete. Obsolete config
will be omitted from the schema, defaults, name constants, etc. The
purpose of keeping a declaration of obsolete config around is to allow
the updater to warn admins that they are using a config variable that no
longer has any effect, and provide them with a remedy.
The idea is that support for deprecated config can be removed after one
release per the stable interface policy, but the declaration of
obsolete config should be kept for as long as we support updates,
that is, at least two LTS releases.
See https://www.mediawiki.org/wiki/Topic:X4bh4nf3pe2ho5jj for
discussion.
Change-Id: Ia7a00742ea7a5311e820a6a43b11135a3f2a825f
Dumping many kinds of object with var_dump() leads to dumping the whole
address space, because a chain of references leads to MediaWikiServices.
So, introduce a trait which replaces the problematic properties with a
placeholder, if their doc comment contains @noVarDump.
Bug: T277618
Change-Id: Ifa685c26fbc5317d0359544289ec3f433ec4fedf
With PHPUnit 9, tests without @covers tags are considered risky and emit
warnings. Not having @covers is bad practice anyway, so use
@coversNothing instead to make the intention clear, and re-enable the
phpcs rule.
Also rewrite an assertion in ResourcesTest that was bothering me.
Bug: T243600
Change-Id: I6dd683f93b6b2faed5f107be2ca7860602277fbc
SettingsBuilder collects warnings about issues with the configuration.
The warnings are so far only surfaced by the installer.
This change adds a structure test that ensures that there are no
warnings.
Change-Id: I92f80ceb8e9eda20ad1de35fa22ed1db7ffcb692
Validating against the live schema on the WMF cluster exposed several
issues with the config schema. Mostly settings declared to be lists
which are actually associative arrays.
This also removes deprecation markers for some settings that are still
in active use, just discouraged or unstable.
Change-Id: I63e816edd1a561bda6063f8558ccce88c113df3f
As we slowly move away from using globals, overrideConfigValue()
and overrideConfigValues() were introduced as a way to override
test configs between tests.
Under the hood, it just calls setMwGlobals() which resets services,
so take note.
Part 1: Directories covered are: languages/, maintenance/, tests/,
structure/ and includes/Permissions/.
Depends-On: I618b16c6d99c94eb2e7edcf05e888a65f7156754
Change-Id: If56f7d10d79f3a9824a52091a2b544d8653dd7b6
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
Unused since change I88754b52c2 (commit 9e95539fc9) – this was only used
for SessionProviders, which is now a map/object instead.
Change-Id: I8da686e6379eb33a63799874fb44f9b0030ab5ba
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
This is a quick find & replace of calls to the deprecated method
ParserOptions::newCanonical() when the context is the string literal
'canonical'. This can be safely replaced by called newFromAnon().
Change-Id: If7bb68459b11e0c5f5de188f10fdae85ad1a78bf
This caused unexpected problems with no obvious fixes. Needs more work.
This reverts commit 7238dff532.
Bug: T310255
Bug: T90875
Change-Id: I3758cbb6d0029b20ec1b0f67dbf2f422031c50ae
* switch to phpunit.xml.dist instead of suites.xml
* switch composer.json to vendor/bin/phpunit
* tests/phpunit/phpunit.php is retained but will be removed after CI
jobs and other references on
codesearch (https://codesearch.wmcloud.org/search/?q=tests%2Fphpunit%2Fphpunit.php&i=nope&files=&excludeFiles=&repos=)
are removed
* add a default bootstrap.integration.php; unit tests in
composer.json use the non-MW bootstrap file (bootstrap.php)
* Migrate the phpunit.php logic into tests/phpunit/BootstrapIntegrationWrapper.php
Depends-On: I19d560bdcdb2ee914ab055e094841f2b5db8be55
Depends-On: Ib23209fc3b095e3c012ed84ce5c11f8b2d27b898
Co-authored-by: Daimona Eaytoy <daimona.wiki@gmail.com>
Bug: T227900
Bug: T90875
Change-Id: I82045c207738d152d5b0006f353637cfaa40bb66
Previously, each of the four derived config schema files had to be
regenerated using a separate maintenance script. This change simplifies
regeneration by combining all for scripts into a single command that can
be used to regenerate all relevant files after changing
MainConfigSchema.
Change-Id: I7d38d8a4aede60475c4bdd0053d2e10e298b9843
We cannot access MW services in a data provider, as MW will not have
bootstrapped by this point in plain PHPUnit. And we do not want to
bootstrap MW by the time a dataProvider is executing, because unit tests
should not need (nor be able to access) MW services.
Change-Id: I21a5993f91b8fbe3fa476a8244b8911cf81e1d5f
The getConfig of a ContextSource should only be used, if the
ContextSource is available. Getting the global context just for the
config looks harder to fix/inject as using the MainConfig from
MediaWikiServices
Change-Id: Iaf14bfc7bd68cc315672e1c256887faf87e22542
Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader itself.
Move the tests by analogy.
I used a namespace alias "RL" in some callers since RL\Module is less
ambiguous at the call site than just "Module".
I did not address DependencyStore which continues to have a non-standard
location and namespace.
Revert of a241d83e0a.
Bug: T308718
Change-Id: Id08a220e1d6085e2b33f3f6c9d0e3935a4204659
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
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
This reverts commit e08ea8ccb9.
Reason for revert: Breaks Phan in extensions, and as far as I’m aware,
this change isn’t urgently needed for anything, so the simplest fix is
to revert it again for now. After PHP 7.4 it should be safer to try this
again (we hopefully won’t need the two “hack” classes by then).
Bug: T308443
Change-Id: Iff3318cbf97a67f821f78e60da62a583f63e389e
Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader and
ResourceLoaderContext.
Move the tests by analogy.
I used a namespace alias "RL" in some callers since RL\Module is less
ambiguous at the call site than just "Module".
I did not address DependencyStore which continues to have a non-standard
location and namespace.
Change-Id: I92998ae6a82e0b935c13e02a183e7c324fa410a3
This introduces static methods for registering classes and namespaces,
so we don't have to mess with global variables and static members
fields.
Bug: T240535
Change-Id: I1abb27bd70898d04c9253e0b7467447fa96d15a4
All the other ways of doing it were ridiculous and much harder to read,
and usually required repeating the needle expression (to get its
length). I found these occurrences by grepping for various expressions,
but I undoubtedly missed some.
I didn't try replacing the many instances of strpos(...) === 0 with
str_starts_with(...), because I think they're readable enough as-is
(although less efficient). Likewise I didn't try porting strpos(...) !==
false to str_contains(...). For case-insensitive comparisons, Tim
Starling requested that we stick with substr_compare() because it's more
efficient than calling strtolower().
On PHP < 8 these functions will be included with a polyfill via
vendor/autoload.php. This is included at the beginning of
includes/AutoLoader.php, so if our autoloader has been included the
polyfill will be available. This means it should be safe to call these
functions from any code that would not be usable without our autoloader.
Three uses that Tim Starling identified as being performance-sensitive
have been split out to a separate commit for porting after the switch to
PHP 8.
Change-Id: I113a8d052b6845852c15969a2f0e6fbbe3e9f8d9
BundleSizeTest is mainly used by skins to test the size of the modules
of the skin. Using default skin may cause unexpected results.
Bug: T305779
Change-Id: Id77c6124c9b1fd20633cda47bbca89f9b6724a63
This reverts commit be7565e3e1.
Reason for revert: Needed for a revert of CentralAuth change I3baf207711.
Change-Id: I847086a8ea2be8931b9f3fc092467445c47644a0
This causes this test case to be run with sql_mode set to
STRICT_ALL_TABLES,ONLY_FULL_GROUP_BY, instead of the default TRADITIONAL
set in DevelopmentSettings. Many database pages (such as those including
a pager) make database connections when loaded without parameters.
If this can be merged without problems it would let us un-revert
Ic2729428297162763a772e6a16549ded8de06c01 too.
Bug: T304762
Change-Id: I3bb424ddcbd7d3d6c03ad23d071a69a94b7f5749
This was changed to support in-place updates of files,
but the idea which was since abandoned. So we can go back to
using stdout.
Change-Id: I825a00258c4f50244679fc47c81b6920dd241647