Commit graph

89 commits

Author SHA1 Message Date
Umherirrender
e662614f95 Use explicit nullable type on parameter arguments
Implicitly marking parameter $... as nullable is deprecated in php8.4,
the explicit nullable type must be used instead

Created with autofix from Ide15839e98a6229c22584d1c1c88c690982e1d7a

Break one long line in SpecialPage.php

Bug: T376276
Change-Id: I807257b2ba1ab2744ab74d9572c9c3d3ac2a968e
2024-10-16 20:58:33 +02:00
Umherirrender
41f6d9eee4 tests: Add missing documentation to class properties
Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.

Once the sniff is enabled it avoids that new code is missing type
declarations. This is focused on documentation and does not change code.

Change-Id: Ifc27750207edc09e94af030d882b6f1a5369cf98
2024-09-18 17:25:42 +00:00
Hannah Okwelum
70e0417c2d Resourceloader: Enable methods that stores and retrieves dependency during test
This was intially disabled in I6c54466e9517d98. Now we use HashBagOStuff during test which doesn't use any database interaction.
So it's okay to enable them now.

Bug: T343492
Change-Id: I0413fc9e302085f27ea9e00eafee23858126426b
2024-09-04 20:15:03 +00:00
Roan Kattouw
8a39d83175 Codex: Allow a local development version to be used
Developers can use this to test their local version of Codex with
MediaWiki by pointing $wgCodexDevelopmentDir to their local clone of the
Codex repo, e.g. $wgCodexDevelopmentDir = '/home/yourname/git/codex';

Setting $wgCodexDevelopmentDir affects where the following things come
from:
- Codex JS/CSS files for the full library
- Codex JS/CSS files for code-split chunks, and the manifest.json file
  that points to them
- Icons retrieved by CodexModule::getIcons()
- CSS-only icons imported in Less
- Design tokens imported in Less

Other changes in this patch:
- Add CodexModule::makeFilePath() to centralize the repeated path
  concatenation. This makes it easier to switch out the regular path for
  the dev mode path.
- Replace all uses of $IP (which is deprecated) and MW_INSTALL_PATH in
  CodexModule with the BaseDirectory config setting.
- Make CodexModule::getIcons() reset its static cache if the path to the
  icons file changes. Without this, it's impossible to make the unit
  tests pass.
- Move the i18n messages code from the CodexModule constructor to
  getMessages(). It can't be in the constructor because makeFilePath()
  doesn't work there (it fails because the Config object hasn't been set
  up yet).
- Add a 'mediawiki.skin.codex' import path so that we can stop
  hard-coding the path to the Codex mixins file. Without this, we can't
  make the Codex mixins come from the right place in development mode.
- Consider $wgCodexDevelopmentDir in setting the cache key for compiled
  Less code, since changing this setting can change the output of Less
  compilation (by changing design tokens, icons or mixins).
- Add unit tests for (the non-dev mode behavior of)
  CodexModule::getIcons() and the i18n message key handling.

Bug: T314507
Change-Id: I11c6a81a1ba34fe10f4b1c98bf76f0db40c1ce98
2024-08-22 17:20:24 -07:00
James D. Forrester
8e940c4f21 Standardise all our class alias deprecation comments for ease of grepping
Change-Id: I7f85d931d3b79da23e87b4e5692b2e14be8fcaa0
2024-03-19 20:11:29 +00:00
James D. Forrester
d6fd1436a3 tests: Namespace ResourceLoaderTestCase and friends
Leave class aliases behind because they might be being used somewhere,
but we don't normally flag these kinds of things in the release notes,
do we?

Bug: T357823
Change-Id: I7fc7f34494d5c4df81f6746d63df1d0f990f8ae9
2024-02-16 21:32:22 +00:00
James D. Forrester
273cc042ae ResourceLoader: Drop targets system, deprecated in 1.41
Bug: T340802
Depends-On: Ie936afed7042d5a4713b027c30d7487565a35eaf
Change-Id: Icad30d62301be5d7390ebdf34e818519e3fe56c4
2024-01-12 16:42:38 -05:00
Fomafix
42b0f55741 Use $this->getServiceContainer() in tests
Use
	$this->getServiceContainer()
instead of
	MediaWikiServices::getInstance()
in tests where possible.

Change-Id: I798b2941f37a43b9073072935b54c3ea0cfe70dd
2023-10-17 18:40:46 +00:00
James D. Forrester
c1599c91b3 Namespace Config-related classes under \MediaWiki\Config
Bug: T166010
Change-Id: I4066885a7ea071d22497abcdb3f95e73e154d08c
2023-09-21 05:41:58 +00:00
Tim Starling
7c2c016e46 ResourceLoader: Implement JavaScript source map support
In the debugger of Firefox and Chrome, without any special debug mode,
you will be able to see the original unminified JavaScript source, and
to set breakpoints in it and step through it.

Main visible changes:

* Add a config variable controlling the generation of source map links,
  off by default for now.
* For script responses, move errors to the bottom of the response. This
  avoids disturbing the source map.
* mw.loader.impl() calls will have less whitespace in debug mode,
  because minification is no longer done as a post-processing step on
  these calls.

Details:

* Use an index map when multiple responses are requested. This requires
  an update to the minify library.
* Add a boolean "sourcemap" query parameter which causes load.php to
  deliver source map output instead of regular minified content.
* Bundle sources into the source map and use two kinds of fake URL if a
  real debug URL is not available. "Open in new tab" on a fake URL is
  not functional.
* In the source map mode, respond with 404 if the version is mismatched
  or if the content type is unimplemented.
* Fix createLoaderURL() so that $extraQuery is not ignored when there
  are conflicting context parameters, so that we can successfully
  override the version. The source map version should match the
  delivered content, not the requested version.
* Since minification with source map tracking can't use filter(),
  add a new cache for module source maps and minification. Add hit rate
  stats.

Also:

* Fix unnecessary array_map() in getCombinedVersion()

Bug: T47514
Change-Id: I086e275148fdcac89f67a2fa0466d0dc063a17af
2023-08-28 21:33:28 +01:00
Tim Starling
69ad795df7 ResourceLoader: Have FileModule deliver additional path information
* Have FileModule::getScript() always return an array with a filePath
  or fakeFilePath, not a string. This allows source maps to be
  constructed.
* Make the scripts returned from Module::buildContent() always be an
  array. Module::getScript() may still return a string for b/c.
* In makeLoaderImplementScript(), interpret the new plainScripts array.
  Factor out the package file normalization loop from
  makeLoaderImplementScript().
* Fix missing base path in mediawiki.base.
* Improve relevant doc comments.

Bug: T47514
Change-Id: I392a8cce9a0febc707b6cb17412e3b723c9cc686
2023-08-23 04:06:20 +01:00
Timo Tijhof
e446a71f86 ResourceLoader: Switch Resources.php to MW_INSTALL_PATH
Follows-up Ib4caa80bb700, which introduced MW_INSTALL_PATH as
alternative to $IP, but also introduced $wgBaseDirectory.

Its not clear to me whether we actually want/need $wgBaseDirectory
long-term as it introduces significant complexity for a distinction
that remains theoretical, not enforced, and lacking a use case.

But, at least here we don't need it as these all explicitly reference
files that are in the source tree. Mocking the path differently would
fail the tests.

There are some individual methods (OutputPage, used via SkinModule)
that do not make assumptions on file paths and work with any file
paths at runtime. Those indeed need $wgBaseDirectory for DI and
testability.

Change-Id: I56c28d36e2d7bbf7ec5a8f2f5ae99b291e7ee4e8
2023-07-31 13:00:27 +02:00
Tim Starling
05c54baa36 ResourceLoader: Add structure test for ResourceLoader::respond()
Confirm that load.php can respond for all registered modules without
errors (except private modules, which can't we don't serve there).

Bug: T47514
Change-Id: I44655b2c05529ae719d71622f57bfed8d632550e
2023-04-10 18:18:54 -07:00
Tim Starling
25d0d37adc ResourceLoader: tweak comments and error messages
Change-Id: Ifcaefedf65b090a87ec1417808277ae6451302dc
2023-04-03 18:21:30 +10:00
James D. Forrester
6c7177349b ResourceLoader: Raise MW JavaScript startup requirement to ES6
The UA sniffs that overrode the feature tests are no longer needed.

* MSIE 10: Fine, rejected by feature checks.

* UC Mini "Speed Mode": Redundant, the version that this sniff
  matched is pre-ES6. Current versions of UC Mini don't appear to
  support enabling "Speed Mode" on random websites nor does it offer
  it for Wikipedia specifically.
  Details at https://phabricator.wikimedia.org/T178356#8740573.

* Google Web Light: Redundant, shutdown as of 2022.
  Any references or extensions that still reach the proxy, get
  redirected to our online URLs
  https://googleweblight.com/?lite_url=https://en.m.wikipedia.org/wiki/Banana
  https://phabricator.wikimedia.org/T152602
  https://en.wikipedia.org/wiki/Google_Web_Light

* MeeGo: Redundant, discontinued and presumed rejected.
  Either way, unsupported.

* Opera Mini: Fine, rejected by checks.
  Details at https://phabricator.wikimedia.org/T178356#8740573.

* Ovi Browser: Redundant, discontinued and presumed rejected.
  Either way, unsupported.

* Google Glass: Improve UX (since 2013, T58008).

* NetFront: Redundant. Old versions are presumed rejected.
  Current versions are Chromium-based and presumed fine.
  The exclusion was not UX based, but due to jQuery explicitly not
  supporting it in 2013. This is no longer the case, so we can let
  the feature test lead the way here.

* PlayStation: Redundant, same story as NetFront.
  The version that matched the sniff is presumed rejected.
  Current versions probably fine, but even not, don't match
  our sniff so are already enabled today.

Bug: T178356
Change-Id: Ib6263ce3ffd11af5e501de8857f3e48a248c6210
2023-03-30 14:26:05 +01:00
Umherirrender
abf2ea44e8 tests: Handle dynamic created properties on test classes
- Declare missing properties
- Remove unused or avoid set of properties
- Add AllowDynamicProperties

Bug: T314099
Change-Id: Ie631894f2ffbb616f6dd09851405d681f3eb8fcd
2023-01-13 21:03:42 +00:00
Amir Sarabadani
bbe704b5c1 Reorg: Move some of request related classes to MediaWiki/Request
Redoing I5ea70120d74 but without moving WebRequest that caused issues
with phan-taint-plugin.

Moving:
 - DerivativeRequest
 - FauxRequest
 - FauxRequestUpload
 - PathRouter
 - WebRequestUpload

Bug: T321882
Change-Id: I832b133aaf61ee9f6190b0227d2f3de99bd1717b
2022-10-28 10:15:31 +00:00
Zabe
f6b9381d7f Revert "Reorg: Move some of request related classes to MediaWiki/Request"
This reverts commit 2bdc0b2b72.

Reason for revert: T166010#8349431

Bug: T166010
Change-Id: Idcd3025647aec99532f5d69b9c1718c531761283
2022-10-27 13:14:16 +00:00
Amir Sarabadani
2bdc0b2b72 Reorg: Move some of request related classes to MediaWiki/Request
Moving:
 - DerivativeRequest
 - FauxRequest
 - FauxRequestUpload
 - PathRouter
 - WebRequest
 - WebRequestUpload

Bug: T166010
Change-Id: I5ea70120d745f2876ae31d039f3f8a51e49e9ad8
2022-10-26 16:49:10 +02:00
Derick Alangi
cb03a63230 tests: Migrate away from setMwGlobals()
Make use of `overrideConfigValue(s)()` where needed and also
make use of MainConfigNames constants.

NOTE: group multiple calls to setMwGlobals() to one and pass
  an array of values instead.
Change-Id: I3bbfd037bb3765c00c426682cce3ef5cccc1a284
2022-08-22 20:17:49 +00:00
Timo Tijhof
519e95adc0 resourceloader: Decouple some internal constructor args
Move config defaults to ResourceLoader class, so that the defaults
reside within the component responsibility, and for future standalone
use and unit testing with the same set of defaults.

Bug: T32956
Change-Id: I4a268e11686e526c4377542d45e198a72e57f182
2022-06-02 18:27:33 +01:00
Tim Starling
3e2653f83b ResourceLoader namespace (attempt 2)
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
2022-05-24 15:41:46 +00:00
Lucas Werkmeister (WMDE)
a241d83e0a Revert "ResourceLoader namespace"
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
2022-05-16 14:43:33 +00:00
Tim Starling
e08ea8ccb9 ResourceLoader namespace
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
2022-05-16 14:41:27 +10:00
daniel
66f3ab254c Remove support for $wgMaxRedirect
Redirect chains have never worked as intended.

Bug: T296430
Change-Id: If0e514c57b8f3d857d956a581f1b549518ecb099
2022-05-06 10:52:56 +02:00
Aryeh Gregor
79fc95d39c Use MainConfigNames instead of string literals, #5
This should be the last of the usages in core, although I'm sure a few
are hiding somehow.

Change-Id: I7bf0b24bf23d3efb4c56a891830bbfe67945e899
2022-04-27 18:46:29 +03:00
daniel
cf581bb2ca Define MW_INSTALL_PATH constant and BaseDirectory config.
Application logic should use the BaseDirectory config variable.
Framework code should use MW_INSTALL_PATH to locate files should.

NOTE: Update https://www.mediawiki.org/wiki/Manual:$IP

Bug: T300301
Depends-On: I7142af16d692f26e90673b058029f572c1ea3991
Change-Id: Ib4caa80bb7007c4c7960a2fd370cf5da7d9ba344
2022-03-04 14:18:27 +01:00
Timo Tijhof
64febce451 resourceloader: Improve wgResourceLoaderMaxage docs, minor clean up
The docs for wgResourceLoaderMaxage still described the "server"
and "client" subkeys, which have not existed since MW 1.35. This
was essentially a new configuration structure, add the `@since`
annotation to reflect this.

Clean up the ResourceLoader class and group together related class
members in a more logical way. Currently going for what I see various
other core components do:

* Constants: public, then private.
* Static: public, then private.
* Members: public (none), then ctor-assigned/injected stuff, then
  those with defaults that start as-is.

Make most protected members private, except for those intentionally
made protected for use in tests. This class is not meant to be
extended, is not marked as stable for that purpose, and Codesearch
shows no extensions that do so.

Remove unused internal '$testModuleNames' field. This was removed in
5f47d994bc and accidentally reintroduced (unused) with 440dfcf6d8,
presumably due to a bad rebase.

Bug: T32956
Change-Id: I041a320d05c9e5f30ac9cc9270ce82c4d19a957f
2022-01-06 18:52:45 +00:00
Timo Tijhof
b99458ceab resourceloader: Fix debug mode for RL-to-RL cross-wiki module loads
The native "foreign module source" feature, as used by the GlobalCssJs
extension, did not work correctly in debug mode as the urls returned
by the remote wiki were formatted as "/w/load.php...", which would
be interpreted by the browser relative to the host document, instead
of relative to the parent script.

For example:

1. Page view on en.wikipedia.org.

2. Script call to
   meta.wikimedia.org/w/load.php?debug=true&modules=ext.globalCssJs.user&user

   This URL is formatted by getScriptURLsForDebug on en.wikipedia.org,
   when building the article HTML. It knows the modules is on Meta, and
   formats it as such.

   So far so good.

3. meta.wikimedia.org responds with an array of urls for sub resources.
   That array contained URLs like "/w/load.php...only=scripts".

   These were formatted by getScriptURLsForDebug running on Meta,
   no longer with a reason to make it a Meta-Wiki URL as it isn't
   perceived as cross-wiki. It is indistinguishable from debugging
   a Meta-Wiki page view from its perspective.

This patch affects scenario 3 by always expanding it relative to the
current-request's wgServer. We still only do this in debug mode. There
is not yet a need to do this in non-debug mode, and if there was we'd
likely want to find a way to avoid it in the common case to keep
embedded URLs short.

The ResourceLoader::expandUrl() method is similar to the one in
Wikimedia\Minify\CSSMin.

Test Plan:

* view-source:http://mw.localhost:8080/w/load.php?debug=1&modules=site
  For Module base class.
  Before, the array entries were relative. After, they are full.
* view-source:http://mw.localhost:8080/w/load.php?debug=1&modules=jquery
  For FileModule.
  Before, the array entries were relative. After, they are full.
* view-source:http://mw.localhost:8080/wiki/Main_Page?debug=true
  Unchanged.
* view-source:http://mw.localhost:8080/wiki/Main_Page
  Unchanged.

Bug: T255367
Change-Id: I83919744b2677c7fb52b84089ecc60b89957d32a
2021-08-25 20:05:38 +00:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
Arlo Breault
fdd8f864b8 Emit media structure as piloted in Parsoid
Gated behind the flag $wgParserEnableLegacyMediaDOM.  The scattershot
usage of it is a little unfortunate but isn't expected to live very long
so maybe that's acceptable.

Further details can be found at,
https://www.mediawiki.org/wiki/Parsing/Media_structure

Bug: T51097
Bug: T266148
Bug: T271129
Change-Id: I978187f9f6e9e0a105521ab3e26821e36a96b911
2021-06-24 23:32:40 +00:00
Timo Tijhof
b7c70526a9 resourceloader: Add missing Module->setConfig() calls in tests and installer
There is a fallback in Module->getConfig() to the global services
container. This is not meant to be used in practice, but there were
two places where this was missing: WebInstallerOutput, and various
PHPUnit tests.

* Add missing setConfig() to WebInstallerOutput.

* Add missing setConfig() to various tests. Most tests were already
  doing this correctly and using the standard mock from
  ResourceLoaderTestCase. Upon switching the last few tests as well,
  I uncovered various errors due to the mock missing some settings
  that the tested code uses, so these have been added now to
  ResourceLoaderTestCase.

Bug: T277728
Change-Id: I44f16ec4e00423fb6f641e58fffc1d40e4571f01
2021-06-13 21:20:58 +00:00
Timo Tijhof
ae1db0cff0 resourceloader: Fix reliance on global state in SkinModule
* Remove odd use of ResourceLoaderFileModule::extractBasePaths()
  SkinModule.php which was basically just returning $IP.

* Use getConfig()->get('ResourceBasePath') so that the test does
  not need to override global configuration variables.

Follows-up 6845912bcf and f1457312dc.

Bug: T277728
Change-Id: I64262b48bb5dc71c53b4114eddb2f080a6a076f5
2021-05-14 20:29:53 +00:00
Umherirrender
a120f1dc87 Use @before/@after in MediaWikiIntegrationTestCase/MediaWikiUnitTestCase
Set functions to final.
This avoids that the function is overwritten without parent call

Follows-up I9d4771c28160356ff58.

Change-Id: I40cde489a892b06284692ecbbef14e650afe7c9e
2021-04-27 22:21:59 +02:00
Daimona Eaytoy
535d7abf59 phpunit: Mass-replace setMethods with onlyMethods and adjust
Ended up using
  grep -Prl '\->setMethods\(' . | xargs sed -r -i 's/setMethods\(/onlyMethods\(/g'

special-casing setMethods( null ) -> onlyMethods( [] )

and then manual fix of failing test (from PS2 onwards).

Bug: T278010
Change-Id: I012dca7ae774bb430c1c44d50991ba0b633353f1
2021-04-16 20:15:00 +02:00
Roan Kattouw
b267f7aa90 resourceloader: Allow modules to mark themselves as ES6-only
Modules that set "es6": true in their module definition will error when
a non-ES6 client tries to load them.

To detect ES6 support, this looks for native Promise support,
RegExp.prototype.flags, and non-BMP characters in variable names. All
browsers that lack full ES6 support fail at least one of those checks.

To flag modules as requiring ES6, this adds a ! to the end of their
version string. This takes up much less space than adding another
register() parameter (which would have to be at the end). It's hacky,
but we expect this feature to be relatively temporary, until we require
ES6 for running any JS at all (probably in about a year).

For distinguishing different types of errors thrown from
sortDependencies(), use e.name. We can't subclass Error properly because
that requires ES6.

Bug: T272104
Change-Id: I45670c910ff12eb422ae54c9fcf372e45c7b2bf1
2021-03-04 14:53:36 -05:00
DannyS712
1567f9bafe Fix extraneous indents in ResourceLoaderTestCase
Change-Id: I5a22337fb1a8098bee526453530c85a8bb18e364
2020-12-18 21:49:07 +00:00
addshore
959bc315f2 MediaWikiTestCase to MediaWikiIntegrationTestCase
The name change happened some time ago, and I think its
about time to start using the name name!
(Done with a find and replace)

My personal motivation for doing this is that I have started
trying out vscode as an IDE for mediawiki development, and
right now it doesn't appear to handle php aliases very well
or at all.

Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
2020-06-30 17:02:22 +01:00
Reedy
ead6b1e53f Fix some PSR12.Properties.ConstantVisibility.NotFound in tests/phpunit/
Change-Id: I0f678049dc274f0cd29f543bb293c33da51d8529
2020-05-09 23:55:09 +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
Umherirrender
97ed35e2e8 Add missing @param and @return to documentation
Change-Id: I48ee838a7ebf4f25a4883d4c7886b39c2d3916af
2019-11-16 13:45:55 +01:00
Max Semenik
48a323f702 tests: Add explicit return type void to setUp() and tearDown()
Bug: T192167
Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43
Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
2019-10-30 14:31:22 -07: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
d6dd6e4d72 resourceloader: Remove use of object registering in test suites
This was done as a "clever" shortcut to make sure tests a little
but shorter, but also made them less consistent with normal code.

Remove this in favour of 'class' or 'factory' options as needed.
Also remove a bunch of unneeded register() calls.

The tests cover everything affected by this change.

Side fix - isFileModule should reject modules with 'factory'
the same way it rejected raw objects and non-FileModule 'class'
cases already. This is now covered by tests as well.

Bug: T222637
Change-Id: I3996317dbcd780cc6e0f82c84e769c08a3fc42bb
2019-07-12 01:17:44 +00:00
Timo Tijhof
a72b082811 resourceloader: Document which FileModule methods use a DB
Also, for the unit test, disable the two methods we use there
that can get called. The unintended side-effects of these two
methods was the only reason it used `@group Database`.
Removing that makes the test a bit faster as well.

Enforce this via MediaWikiServices for this suite to avoid an
untracked dependency slipping back in in the future.

Bug: T225730
Change-Id: I6c54466e9517d9899bc39f8f9bb946369c0a526d
2019-06-19 23:44:39 +01:00
Timo Tijhof
469d961bb7 resourceloader: Switch Xml::encodeJsCall call in getDeprecationInformation
Also rename one of the test classes to have a more descriptive name.

Bug: T32956
Change-Id: I1a970c198300b7ef0d99c15609f1fb7fa8783b98
2019-06-19 15:54:08 +01:00
Timo Tijhof
d9a5806940 resourceloader: Convert test for FileModule versionHash to data provider
In prep for the next commit.

Change-Id: If08c3d8b769b6ec03faf8ff24f216ce9f670f6ac
2019-06-12 15:11:18 +01:00
Timo Tijhof
c9318edc2d resourceloader: Warn on ResourceLoader::construct without Config
The only remaining use of 'new ResourceLoader' is in tests, which have
been migrated in this commit to either passing the real config explicitly
(for integration tests), or by passing a HashConfig from a new
'getMinimalConfig' method which has only the keys required for the tests
to pass (e.g. avoid any ConfigExeption for unknown keys).

Also clean up some related code quality issues:

* Migrate wfScript() to $conf->get() so that the local Config is used,
  instead of implicitly using global variables. This isn't deprecated for
  MediaWiki generally, but done here to prepare ResourceLoader for becoming
  a standalone library.

* Remove mocking of 'CacheEpoch' config, this is no longer used anywhere
  in ResourceLoader.

* Change EmptyResourceLoader to use the minimal config by default and
  remove code duplication by calling the parent.

  Update the small number of uses that are integration tests, to explicitly
  pass in the live config as needed. And for the one case that tests the
  'startup' module, it no longer needs to register it manually given this
  is part of ResourceLoader::__construct() by default.

Bug: T32956
Change-Id: I127346fd530fa66f205156e545758b1c29d0fac0
2019-06-10 15:24:45 +00:00
Reedy
9f2ffdfbd4 Remove "Squiz.WhiteSpace.FunctionSpacing" from phpcs exclusions
Change-Id: I78b3315f26ab91b6b443f5b028a635552f82f5a3
2019-05-11 02:44:26 +01:00
Timo Tijhof
b54a1e709e resourceloader: Use 'fallback' as default for ResourceLoaderTestCase
Follows-up fa05976f5f. This broke the Travis CI tests because
the Vector skin is not installed there (unlike in Wikimedia CI).

Make the test no longer reliant on that detail.

* Fix ResourceLoaderTestCase to use a default that actually
  works in plain core (previously 'vector' would be rejected
  as being an unknown skin, but then be re-normalised back to
  'vector' thanks to wgDefaultSkin. This was fixed in fa05976f5f,
  and the unknown skin now produces 'fallback' which is better.

* Update ResourceLoaderOOUIImageModuleTest to match this
  new default and also fix the test message while at it
  to mention 'skin', not 'image'.

Change-Id: I5fb69a6a38a42b1a5f325c0134e01ad880f65087
2019-04-15 20:21:00 +01:00