Commit graph

435 commits

Author SHA1 Message Date
Thiemo Kreuz
b0130ca649 Update a lot of unspecific "array" types in PHPDocs
This includes fixing some mistakes, as well as removing
redundant text that doesn't add new information, either because
it literally repeats what the code already says, or is actually
duplicated.

Change-Id: I3a8dd8ce57192deda8916cc444c87d7ab1a36515
2020-10-28 11:01:33 +01:00
Florian
43d5307715 Fix PHP 8 compat with strcspn() $length parameter exceeding string
Bug: T264502
Change-Id: I25cb8f56e6f56a9233e38844dc62cda9a06cb5e6
2020-10-04 01:27:47 +00:00
Timo Tijhof
d04f04097a resourceloader: Use a local HookRunner
Also move ResourceLoaderRegisterModulesHook under the same
namespace. I forgot this one in commit b7ac554304.

This is mainly motivated by making the collaboration graph
on doc.wikimedia.org not huge by pulling in the full range
of core hook interfaces.
<https://doc.wikimedia.org/mediawiki-core/master/php/classResourceLoader.html>

Depends-On: Ifa53d96dd3e4592208dbc991e2af9e6b7598e44d
Depends-On: Ib4571d80f55a4716e28b76ba1d007f95b0fb2540
Change-Id: I576305a5edb36a2ffb513e6d557bbf1d337cb17e
2020-09-17 01:53:18 +00:00
Timo Tijhof
0c01d8cc52 resourceloader: Add skin-based 'mediawiki.skin.variables.less' import
Add the SkinLessImportPaths attribute for skin-specific LESS import
paths, which skins can use to override the mediawiki.skin.variables.less
file.

As a starting point, add the following 5 variables:

* device widths (3x)
  To help phase out 'mediawiki.ui/variables'. These are
  commonly used by MobileFrontend.

* @font-family-sans
  Recommended by Volker. Used by multiple skins.

* @border-radius-base
  Recommended by Volker as example of something that we currently
  hardcode in MediaWiki core for Vector and OOUI/WikimediaUI
  in 'mediawiki.widgets.datetime' but should instead be allowed
  to vary by skin and OOUI theme.

  Remove the hardcoded value for '@border-radius-base' in
  various places in favour of importing from mediawiki.skin.
  The default is a bare default of 0 (as border-radius is off
  by default in the browser).

  The value for Vector is restored there by I47da304667811.
  The value for MonoBook is improved by I000f319ab31b.

Bug: T112747
Change-Id: Icf86c930a3b5524254bb549624737d3b9dccb032
2020-09-15 10:05:53 +00:00
jenkins-bot
fc2dfae54a Merge "resourceloader: Document that ResourceLoader::applyFilter can return null" 2020-07-08 18:10:47 +00:00
DannyS712
a20ac7bb67 resourceloader: Document that ResourceLoader::applyFilter can return null
Also fix the bug where the fallback in ResourceLoader::filter
did not work for the cache=false case.

Change-Id: Iffe4cdd7b847f2a22aeaff2cf61c2104ec217f04
2020-07-08 17:46:27 +00:00
Timo Tijhof
91c73f6bac resourceloader: Add some typehints and misc clean up
* Add a void return hint to methods that are not meant to return
  anything. This helps catch accidental return statements in the
  future, lets Phan better understand how methods are meant to be
  used, and might also allow PHP to better optimise the compiled
  code form (speculation).

  I did not, however, add it to publicly extended methods as that
  might mess with strict mode.

* Remove the internal getResourceLoader() method from MessageBlobStore.
  This has been redundant since 3edaa0b37c.
  The method was protected, and not considered stable to subclass
  for extensions. Hence not a breaking change.

* Add Throwable typehint to formatException() and friends.
  This is the narrowest one I could add given that the methods
  called from here already enforce the same typehint.
  Update the doc to match for now. There isn't a reason right now
  to limit this only to Exception, and given this is the method
  and not the catch statement itself, does not change behaviour.

* Remove unused ResourceLoader->getHookContainer().
  Added within 1.35 cycle, safe to remove.

* Remove unexpected `@since` for `@internal` getHookRunner().

* Remove redundant `@internal` from ResourceLoaderMwUrlModule
  methods, which itself is already `@internal`.

Change-Id: I68d33ff6feca7ef95282a7ff03eb9332adfde31c
2020-07-02 03:05:59 +01:00
Tim Starling
68c433bd23 Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.

General principles:
* Use DI if it is already used. We're not changing the way state is
  managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
  is a service, it's a more generic interface, it is the only
  thing that provides isRegistered() which is needed in some cases,
  and a HookRunner can be efficiently constructed from it
  (confirmed by benchmark). Because HookContainer is needed
  for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
  SpecialPage and ApiBase have getHookContainer() and getHookRunner()
  methods in the base class, and classes that extend that base class
  are not expected to know or care where the base class gets its
  HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
  getHookRunner() methods, getting them from the global service
  container. The point of this is to ease migration to DI by ensuring
  that call sites ask their local friendly base class rather than
  getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
  methods did not seem warranted, there is a private HookRunner property
  which is accessed directly. Very rarely (two cases), there is a
  protected property, for consistency with code that conventionally
  assumes protected=private, but in cases where the class might actually
  be overridden, a protected accessor is preferred over a protected
  property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
  global code. In a few cases it was used for objects with broken
  construction schemes, out of horror or laziness.

Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore

Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router

setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine

Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-05-30 14:23:28 +00:00
Timo Tijhof
88d01fb42b resourceloader: Make DepStore write lock specific to the current wiki
Follows-up I6da55e78d5. The makeKey() call was accidentally lost,
thus the locks became shared across all wikis.

Bug: T113916
Bug: T247028
Change-Id: Id459120965c9a6d3b68a028d2c69dc042277b5d2
2020-05-18 23:52:20 +01:00
Reedy
b80a9f4f6a Fix even more PSR12.Properties.ConstantVisibility.NotFound
Change-Id: I5e04824d6fa6a4c36ce489850bb0ed7b4ac588f9
2020-05-16 00:51:14 +01:00
Timo Tijhof
b7ac554304 resourceloader: Move RL hooks to own namespace, use PSR-4
Follows-up f5aaf75ad1.

* Improve some docs for these hooks.
* Add type hints.
* Add them as a subgroup within the ResourceLoader docgroup
  for easy navigation.

Bug: T246855
Change-Id: I52f31e2b63dcf265b27e68ba8fd4f885d82088ac
2020-05-04 22:42:00 +00:00
James D. Forrester
ac6624d7ae resourceloader: Drop wgEnableAPI/wgEnableWriteAPI from mw.config
Deprecated and always true since 1.32.

Change-Id: I45f24b20ae4466e367019e55677e608ae8a34374
2020-04-28 18:53:13 +00:00
Timo Tijhof
851eb4b9c8 qunit: Use "test.*" module names only for actual test suites
This will make it easy to later allow the user to select which
component's specs to load and run (via CLI and GUI), e.g. for
an entire extension. We currently only have very narrow or very
wide selection mechanisms ('module' param for 1 module,
'rerun' for 1 test case, 'filter' param for global pattern match).

Bug: T250045
Depends-On: I55fe27e1c74972fcb3cdafefdc78e10e24f95b80
Change-Id: I5c01f720d787c3847228de511ce913284786ad66
2020-04-22 21:11:12 +00:00
Timo Tijhof
69e9b31fc5 resourceloader: Export ResourceModuleSkinStyles as extension attribute
Instead of exporting this as a global variable, export it as an extension
attribute.

The $wgResourceModuleSkinStyles configuration variable will continue
to be supported for its main purpose of setting skin styles. However
it may no longer be used to read these settings. The canonical copy
of this is now restricted to the ResourceLoader class and not (yet)
made publicly available (I found no use cases for it).

This opens the door to making it lazy-loaded attribute, which would help
reduce the size of the "main" APCu cache key for ExtensionRegistry.

This is not possible with global variables as those must be exported
unconditionally from Setup.php.

Bug: T32956
Bug: T247265
Change-Id: I4ecf558d9c630c91959786d2573c34e619223cef
2020-03-30 16:08:00 -07:00
Thiemo Kreuz
6b2c9deef5 Replace all new stdClass() with identical (object)[]
This should be the exact same. Its more a style change than anything.
So why do it then?
* I believe this is much less confusing than code mentioning a weird
"standard class". Barely anybody knows what this is, and what the
difference between "object" and "stdClass" is.
* The code is shorter.
* It's even faster. In my micro benchmark it's twice as fast.

Change-Id: I7ee0e8ae6d9264a89b6cd1dd861f0466ae620ccc
2020-03-04 21:18:30 +00:00
Timo Tijhof
95ec909e52 WikiMap: Add WikiMap::getCurrentWikiId() to make common use case easier
Change-Id: Ie225ebfc37c824e3167742137bbbc9f64aca5f5e
2020-03-03 16:04:21 +00:00
jenkins-bot
05b1712cbe Merge "resourceloader: Add more granular phan type information in various classes" 2020-02-27 21:21:26 +00:00
Timo Tijhof
f575721a06 Update all use of $wgVersion to MW_VERSION
Follows-up I04628de4152dd5.

Bug: T212738
Change-Id: I718474ec0d9fd29ac2c05477f0f2493615d8aff5
2020-02-25 02:16:12 +00:00
Timo Tijhof
a3ce1f9da7 resourceloader: Add more granular phan type information in various classes
* Where possible and easy to figure out, change `array` to something like
  `array<K,V>` or `V[]` for improved static analysis to catch/prevent
  regressions in CI.

* Minor doc improvements:
  - consistently use the imperative mood for method briefs,
  - consistently use @internal instead of @private,
  - explain in @throws why they happen to inform when they should be caught
    (and remove if they are not meant to be caught/handled by any caller).

* Simplify addSources() implementation as a simple loop instead recursing
  (not worth the complexity, only called once or twice at runtime).

* Use more granular exceptions to distinguish between errors that indicate
  a mistake on the caller (logic/invalid arguments error), and runtime
  errors (which are more circumstantial).

* Update register() unit test for bad 'moduleInfo' type to use
  a nested value, given that the second-parameter level type is
  now verified by the signature already.

Change-Id: Id98ba1f28cb7f1c72f0a3e82f4151bcbd0f3db77
2020-02-21 23:54:33 +00:00
Kunal Mehta
a0ce12999a registration: Cache lazy-loaded attributes and make easier to use
This allows us to move things that are not used on every request (e.g.
'TrackingCategories') into separate cache entries to slim down the main
one.

At the same time, fold getLazyLoadedAttribute() into the standard and
already established getAttribute(), so that client code doesn't need to
be aware of whether something is lazy-loaded or not, it'll just work.

Everything is still cached using the load queue as part of the cache key
for instant invalidation, so if an extension.json file changes, the
lazy-loaded attribute cache will invalidate too.

The cache is populated whenever loadFromQueue() happens, but if it
happens to fall out of the cache, then getLazyLoadedAttribute() will
iterate over all the loaded extension/skin.json files to read that
value. Since we end up reading everything, we populate all of the
caches again.

The caching logic was split into two more private functions
(::getCache() and ::makeCacheKey()) for easier internal reuse.

Bug: T220994
Change-Id: I290926bbedfc964195d1f576a9e06349f9e5d5ea
2020-02-17 22:18:10 -08:00
Aaron Schulz
5282a02961 resourceloader: support tracking indirect module dependency paths via BagOStuff
This can be enabled via a configuration flag. Otherwise, SqlModuleDependencyStore
will be used in order to keep using the module_deps table.

Create a dependency store class, wrapping BagOStuff, that stores known module
dependencies. Inject it into ResourceLoader and inject the path lists into
ResourceLoaderModule directly and via callback.

Bug: T113916
Change-Id: I6da55e78d5554e30e5df6b4bc45d84817f5bea15
2020-02-13 17:26:36 +00:00
Derick A
35357ce3fe resourceloader: Dependency inject WANObjectCache into MessageBlobStore
Change-Id: I0f4c4e0e753574cf060331c944f44318eaca1fec
2020-02-12 22:16:42 +00:00
Derick A
fb5650684a resourceloader: Optimization - avoid repeated $this->getModule() calls
`$this->getModule()` returns a RL object or a null. The check above already
makes sure that $module is not null so we can just set file dependencies
from the RL object returned.

In addition, this is an optimization as we reduce repeated calls to
`$this->getModule()`. Similar logic already exist in the same file from
L#116 - L#118.

Change-Id: If50c28ff5cd8eb435c9fa4f277e2d1038b52ca74
2020-02-09 21:18:44 +01:00
Brad Jorsch
036cde7a04 resourceloader: Move site-level mw.config from startup to mediawiki.base
This data isn't needed for startup, and we can shave off a few K from
startup by moving it to mediawiki.base instead.

It was requested that this be done as a "package file", which
necessitated some other minor structural changes to mediawiki.base as
well.

Bug: T235350
Change-Id: I525a5203533089d5a542f83a847be58a10cb6319
2020-02-07 19:44:57 +00:00
James D. Forrester
0958a0bce4 Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNull
Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
2020-01-10 14:17:13 -08:00
Kunal Mehta
d6390ba1ee registration: Implement lazy-loaded attributes
These attributes are only accessed at a time when performance isn't
critical (e.g. tests), so we can skip caching them and read each
extension.json file again when we do need them.

At the same time, we want to reduce the size of the array that we're
caching due to PHP 7 performance regressions with APC (T187154).

'QUnitModules' is the first attribute to be converted into a lazy-loaded
attribute.

Bug: T220994
Change-Id: I224cdace05dbac00ff947c41daecb74b07c967bb
2019-12-15 19:04:50 +00:00
Timo Tijhof
9c0dee3965 resourceloader: Use ConvertibleTimestamp and Logger directly
Avoid use of wfTimestamp and wfDebugLog global functions.

Also simplify some of the error messages around processing of
'packageFiles' definitions and throw generic LogicException
instead of MWException.

Change-Id: I55ce1f107f53dfdfe673cbe4411b0a7c4e24b2ea
2019-12-04 16:24:40 -08:00
Umherirrender
c7ad21c25f Improve param docs
Change-Id: I746a69f6ed01c3ff000da125457df62b02d13b34
2019-11-28 19:08:59 +01:00
Brian Wolff
67ea4f5747 Mild refactoring of ContentSecurityPolicy
This is to make it behave in a more object orientied way. The
goal is to make it be easier to allow extensions to mark certain
pages as requiring a different policy (For example, CodeEditor
extension uses a blob: url with a WebWorker. We don't want to
include that on the policy of every page, but allow the extension
to mark it as required whenever needed).

This commit does not change code behaviour in any way.

Change-Id: I4bf53dabb6e6c5446cea99a64db68b300cef2fd4
2019-10-28 09:02:14 -07:00
Ammar Abdulhamid
0454b34c4d resourceloader: Simplify $wgResourceLoaderMaxage config
Remove support for the 'client' and 'server' subkeys.

Bug: T235314
Change-Id: Ibeb2404b0f7dc8a9198e73344d54a3cb0176de08
2019-10-19 21:28:58 +01:00
Daimona Eaytoy
bd5b6f98ba Fix new phan errors, part 3
These are almost only doc changes, with two exceptions:
1-In LinkHolderArray, int-alike array keys are now cast to int, to be uniform with what we do in other code paths
2-In ExtensionRegistration, changed a line to throw an Exception
immediately, instead of an ExtensionDependencyError. This is because the
latter takes an array with msg and type, but we were passing it a plain
string (and in fact the code was bugged).

Bug: T231636
Change-Id: I8b0ef50d279c2a87490dde6a467a4e22c0710afd
2019-10-12 10:35:22 +00:00
Fomafix
7c7f3efcb8 resourceloader: Drop deprecated ResourceLoader::getLessVars
ResourceLoader::getLessVars is deprecated since ca510f742 included in
MW 1.32 and hard-deprecated since 1b32592d9 included in MW 1.34.

Bug: T140804
Change-Id: If88c71ed7fdf3c6a5cf89a50197e246c201ebaa2
2019-10-09 22:31:52 +00:00
Fomafix
a9823d16f6 resourceloader: Add array type hints
Change-Id: I4844eae68e85adc46e52646ea066b459bbabdcce
2019-10-05 15:26:56 +00:00
Fomafix
1b32592d9c resourceloader: Hard deprecate ResourceLoader::getLessVars
ResourceLoader::getLessVars is already deprecated since MW 1.32.

Change-Id: If2fbe7828d8cde73575c0306486835fa1ea06b84
2019-09-30 00:07:30 +00:00
Fomafix
9d2d608993 resourceloader: Simplify makeLoaderStateScript and makeLoaderSourcesScript
The signatures without array are not used anymore.

Change-Id: Ice6a09ff6cba0c605ed1c89a25fd8e02af041b05
2019-09-28 18:26:40 +00:00
jenkins-bot
1791c92893 Merge "resourceloader: Add $modules parameter to makeVersionQuery()" 2019-09-28 01:26:59 +00:00
jenkins-bot
5155abe0e6 Merge "resourceloader: Add $context to static functions in ResourceLoader" 2019-09-27 20:48:15 +00:00
Fomafix
2fc229116d resourceloader: Add $context to static functions in ResourceLoader
This change allows to use the context in the functions.

The following internal static functions from ResourceLoader get now a
reference to the ResourceLoaderContext object:
* makeLoaderImplementScript
* makeLoaderStateScript
* makeLoaderRegisterScript
* makeLoaderSourcesScript

ResouceLoader::encodeJsonForScript is duplicated to
ResourceLoaderContext::encodeJson loading the debug mode from context.

ResourceLoader::encodeJsonForScript is kept for other usages without
context.

The debug mode is loaded from $context->getDebug() instead of from
ResourceLoader::inDebugMode(). This does not support to enable the debug
mode by setting the cookie 'resourceLoaderDebug' or the configuration
variable wgResourceLoaderDebug. Only the URL parameter debug=true
enables the debug mode. This should be sufficient for the subsequent
ResourceLoader requests. The tests don't need the global variable
wgResourceLoaderDebug anymore. The initial ResourceLoader context in
OutputPage still uses ResourceLoader::inDebugMode() with cookie and
global configuration variable.

This change adds the parameter $context with a ResourceLoaderContext
object to ResourceLoaderModule::getDeprecationInformation and deprecates
omitting the parameter. Ifa1a3bb56b731b83864022a358916c6aca5d7c10
updates this in extension ExtJSBase.

Bug: T229311
Change-Id: I5341f18625209446a6d006f60244990f65530319
2019-09-27 18:35:55 +02:00
Timo Tijhof
e6ff1ff915 resourceloader: Add $modules parameter to makeVersionQuery()
The 'version' and 'modules' parameters are a somewhat problematic
part of the ResourceLoaderContext object as we often pass around
the context but may be dealing with only a subset of the modules
in the outer request, or even entirely different ones (e.g.
for OutputPage's fake context 'modules' and 'version' are both
null).

This is already visible in ClientHtml where we create a derivative
context just to call setModules() and have makeVersionQuery()
work. This is now fixed.

This change is in preparation for use in ResourceLoaderImage
(to fix T233343) where we'll need to compute a version for only
1 module of a larger set, and ideally without needing to create
another context.

Bug: T233343
Change-Id: Icc1a4fd1f58c4e49e58eee43ca4ba2de6cfffc76
2019-09-26 22:30:07 +00:00
Timo Tijhof
a5ce1d7792 resourceloader: Add Doxygen group and improve overall docs
* Add license header where missing.
* Add missing `@since` (1.17 for most classes), except
  ResourceLoaderLessVarFileModule since 1.32 (1bc62c548c).

* Remove duplicate file-level description for class-only files,
  merge with the class description instead.

* Remove my own `@author` annotation from one file.

* Mark core's own FileModule subclasses as `@internal`, except
  for the following which we support use of in extensions:
  ResourceLoaderLessVarFileModule,
  ResourceLoaderOOUIIconPackModule, and
  ResourceLoaderWikiModule.

Change-Id: I336af2e4ccdbe2512594e8861b72628d24194e41
2019-09-14 18:37:36 +00:00
Fomafix
d78d9fe3fb resourceloader: Replace Xml::encodeJsCall by encodeJsonForScript
Also document that encodeJsonForScript can return false on invalid UTF-8
characters.

Bug: T32956
Change-Id: I9c2fd33fb2130ada67fa70ff176e5488f1a014bf
2019-09-10 12:51:16 +02:00
Fomafix
a253c6d56c resourceloader: Remove comment about XmlJsCode wrapper
The support for the XmlJsCode wrapper got removed in 23d066618d.

Change-Id: If14065277699aa9cca70107ff0174bd51f757c31
2019-09-10 07:30:07 +02:00
Umherirrender
8e7b469a12 resourceloader: Document encodeJsonForScript() type as mixed
Objects passed to it since 23d066618d
json_encode allows mixed type, so use it also here.

Change-Id: I0897a6a144fd1c90b3ead205cedf21c19682b9df
2019-09-04 20:11:38 +00:00
Timo Tijhof
9f516f1d3b resourceloader: Reduce width of module hash from 7 chars to 5
In a nut shell:

* We very often (52% of modules on enwiki) pad the hash with a zero,
  which means the amount of bits we currently compute already fit in
  6 characters already for most modules. For some modules (3%) we
  even padded two zeroes.

* For the (now documented) use cases, the space of 78 Giga
  (78 billion, or 78 milliard) seems more than we need. The space of
  60 million should be enough.

  This follows-up dfd046412f from 2016, which previously shortened the hash
  down from 8 chars of base 64 (or 12 chars of hex) to 7 chars of base 32.
  Before that change, the space was 281 Tera (64^8, or 16^12).

For more details see the added inline comment for ResourceLoader::makeHash,
and also the data at <https://phabricator.wikimedia.org/T229245>.

Bug: T229245
Change-Id: I9ad11772a33b3a44cb625275b1d7353e1393ee49
2019-09-02 01:25:48 +00:00
Timo Tijhof
e1bf44cd21 resourceloader: Add tests for disallowing access to private modules
* Add a test to confirm that the ResourceLoader::respond() logic
  works as intended.

* Remove the client code for preventing it from being loaded.
  This can never happen in production unless there is a bug.
  Instead of optimising to avoid a pointless request that only
  happens when the software is broken, instead optimise for when
  the software is not broken by just letting it happen. The server
  already handles it just fine.

  This was originally added in 2015 with 1dd7390372 to reduce
  logspam, but that was instead fixed in 6d6b037e12 by making the
  log message debug-only (because it's not a software problem,
  it's a client-error, e.g. a broken user script or a third
  party trying out different things on the load.php entry point).

  Removing this makes the client a bit smaller, too :)

Change-Id: Ic5420d9329a73514f4fc27baa46ae58d94addafb
2019-08-24 20:36:37 +01:00
Aaron Schulz
440dfcf6d8 Reorganize ResourceLoader fields
Change-Id: I9c9aece69b869165b8d9037336c8a2e7d7189c1e
2019-08-02 14:54:40 -04:00
jenkins-bot
5e2788a0c5 Merge "resourceloader: Merge $fileCache conditional blocks" 2019-08-01 21:52:48 +00:00
Timo Tijhof
5f47d994bc resourceloader: Don't explicitly enqueue test libs on SpecialJavaScriptTest
The test-only modules registered by QUnitTestResources.php are currently
were previously caught by the array_keys() catch-all in registerTestModules()
which meant that modules like 'test.sinonjs' would be requested on
SpecialJavaScriptTest despite not doing anything by itself, nor executing
at the "right" time per se through this means.

In order for it to execute at the right time, the testrunner has to depend
on it (which it does, already). But, that also means it doesn't need to
be requested separately. Doing so could be confusing.

This is neccecary in order to move 'jquery.qunit' from Resources.php
to QUnitTestResources.php as otherwise, listing in QUnitTestResources.php,
would implicitly mean SpecialJavaScriptTest.php thinks it's a test suite
and load it. That is a problem, because when we run the tests headless from
the command-line with Karma, the environment already has a QUnit interface
defined, and should not be loaded a second time by MW.

Change-Id: I08b31cd1dee516cf0d26bafdb8cc7c1223633bad
2019-07-30 16:00:49 +00:00
Timo Tijhof
69016bd2c3 resourceloader: Merge $fileCache conditional blocks
Also avoid conditional existence of variables ($fileCache). This avoids
isset(), which means we won't hide problems during refactor.

Raised by Codehealth (sonarcloud.io) as Major Code Smell:

> Merge this if statement with the enclosing one.
> https://sonarcloud.io/organizations/wmftest/rules?open=php%3AS1066&rule_key=php%3AS1066

Change-Id: Iacebbe6a68dac46cdfd1415a33a547d105b24b98
2019-07-27 14:29:37 +00:00
Timo Tijhof
1dd7af5754 resourceloader: Remove incomprehensible @todo in getTestModuleNames()
I added this 7.5 years ago with r111378 (5bf04171dc), but I can't
recall what this would have been for. Perhaps we wanted to expose
the list of modules (or test frameworks) via ApiQuerySiteInfo, but
I don't know why, or what purpose it would serve.

Change-Id: I4005979252533a752178e6f1ac9900f32132c27e
2019-07-25 23:46:11 +01:00