Commit graph

215 commits

Author SHA1 Message Date
Timo Tijhof
fcd799ad54 resourceloader: Let wgResourceLoaderMaxQueryLength=-1 fallback to default
Follows-up 3ac385a0c3. This was generated by the installer at some
point and we've received two user reports of someone being caught by
this. We don't need to support "unlimited" anymore, but at least make it
do something more sensible, like using the default of 2000.

Previously, it was effectively treating the -1 like 0,
which was causing "debug mode"-like behaviour for end users.

Bug: T251789
Change-Id: I483d5312e6fa25a0b00bb6173ed01eeb99ad42aa
2020-05-08 00:18:42 +00:00
Derick A
873f833961 resourceloader: Fix typographical errors in RL files
Change-Id: I8486dcb70e143766a10e6e50bb99d491e6be322d
2020-02-09 21:53:26 +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
Roan Kattouw
4bcfeba16e resourceloader: Fix typo in StartUpModule dummy output
It's only=scripts, not only=script. As written, following the
instructions in the comment that StartUpModule returns when you're using
it wrong doesn't work, this fixes that.

Change-Id: Ib0cb2ce18dbc446dc3c5f3c670b4c29064d000d9
2019-12-17 12:56:53 +01:00
Timo Tijhof
ae08640853 OutputPage,ResourceLoaderStartupModule: Separate internal from public config vars
Change-Id: Ic54d3b36fb379d77139b21b46db7da9f78869e37
2019-10-31 19:35:45 -07:00
jenkins-bot
44f51fcf90 Merge "resourceloader: Use PHP7 return hints in StartupModule and Context" 2019-10-27 10:01:05 +00:00
Daimona Eaytoy
b5f0d61ee4 Fix new phan errors, part 8
Bug: T231636
Change-Id: I61852ba55362ab9ae8cc8c1ab6b27565ce1d08e7
2019-10-22 10:09:13 +02:00
Timo Tijhof
d3fdd4a3e7 resourceloader: Use PHP7 return hints in StartupModule and Context
Change-Id: I1aaa3a7274e84d2c872d7b75ea602aeeddd0a0c0
2019-10-19 00:33:35 +01:00
Timo Tijhof
15fb9f22db resourceloader: Expose StartupModule::getConfigSettings for internal use
Bug: T235350
Bug: T229836
Change-Id: Ia368ddcc650cdad07c48a93c6aaae24627e73458
2019-10-12 20:49:12 +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
Fomafix
69981b6476 resourceloader: Add type hints for type ResourceLoaderContext
Change-Id: I10fc4b9277f94fc495149fe0d0077b054090387b
2019-09-27 06:43:44 +02: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
Jack Phoenix
495f9fa290 resourceloader: Add $conf parameter to the 'ResourceLoaderGetConfigVars' hook
Change-Id: I3cca8ce87b303ef7dfd96bfe1fdda0c51c441f6f
2019-09-07 15:30:40 +00:00
jenkins-bot
75e2607211 Merge "resourceloader: Reduce width of module hash from 7 chars to 5" 2019-09-03 19:21:39 +00:00
Roan Kattouw
d45baf7f07 resourceloader: Add wgWikiID to mw.config in the startup module
This was previously just added by Echo, but it's generally useful.

We should probably deprecate wgDBname, because wgWikiID is a better wiki
identifier that also works when two wikis have different table prefixes
in the same database, but that'll take some work because a number of
things rely on it right now (including ResourceLoader itself, for its
localStorage keys).

Change-Id: I4d289267991f1f9a8e0710ec6ee5a2131306c510
2019-09-03 17:48:23 +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
Amir Sarabadani
c59b0ed189 resourceloader: Map group names to integers internally
This makes startup response smaller.

Change-Id: Id0ae3cd7cd22163f42b92b629c38b0a806d3ca50
2019-08-24 20:36:37 +01:00
Timo Tijhof
ed6e38178b resourceloader: Merge mediawiki.legacy.wikibits into mediawiki.base
Still executed under the same conditional, but no longer exposed
as its own public module bundle.

Change-Id: Ifba3a73b184ce02eeeeb2ccce6d4aece732dea13
2019-08-03 21:49:20 +00:00
Timo Tijhof
3857d06f1c resourceloader: Remove unused 'getBaseModulesInternal' internal method
I added this as wrapper for the private 'getBaseModules' method
in commit dec800968e for "use by SpecialJavaScriptTest", but
I never did. And it doesn't need it so.. let's remove that.

Change-Id: Ia301bd1c1f3a15098b9e6cd2934dd8e80879dd50
2019-08-02 20:33:08 +01:00
Timo Tijhof
8199e028fd resourceloader: Remove slow structure test for checking getVersionHash
This isn't needed because the startup module validates this already.

The vast majority of modules are FileModule instances which can't be invalid,
because a separate test asserts that class already. This test existed for
validating the format of version hashes returned by a theoretical Module
sub class in an extension that (badly) overrides the getVersionHash method.

As of writing, no extension overrides that method. And more importantly,
the startup module already validates this at run-time, and logs a warning.
This commit turns that into an exception, which would get logged in a way
that Jenkins will fail the build if encountered.

This structure test, which computed the response for all registered modules,
previously took 3-5 seconds in CI.

Bug: T225730
Change-Id: Id2e37434b0ccd95dd2279f04e2230e9c06b09ccb
2019-08-01 15:33:23 +00:00
Timo Tijhof
a7017dbc0a resourceloader: Move 'mw.config' assignment from startup.js to mediawiki.js
Before this change, the startup module responds as follows:

   ```lang=js
   ... contents of startup/mediawiki.js:
   ...... mw.config = null;
   ...
   ... contents of startup/startup.js:
   ...... mw.config = new mw.Map( bool );
   ```

After this change:

   ```lang=js
   ... contents of startup/mediawiki.js:
   ...... mw.config = new mw.Map( bool );
   ...
   ... contents of startup/startup.js:
   ......
   ```

Change-Id: I97fea20f17c4865aa4740482f3054532038531f0
2019-07-25 18:21:51 +01:00
Timo Tijhof
c6ebce6a7d resourceloader: Remove internal 'wgResourceLoaderStorageEnabled' from mw.config
Only needed internally by the startup module, which can export it
through private means instead.

Follows 0a8e37f042 and 30ddfc8a77.

Change-Id: I5e54bd51d9b47146e1ef9a64b14c1a00697bd6a9
2019-07-25 17:41:06 +01:00
Fomafix
30ddfc8a77 resourceloader: Set value for getStoreKey in server-side
This change reduces the size of the JavaScript resources.

Change-Id: I850249f910f6275c1b963dc5421ba706ed6e9a56
2019-07-04 17:48:34 +01:00
Fomafix
0a8e37f042 resourceloader: Set value for getVary in server-side
This change makes ResourceLoaderStorageVersion a private variable.
The JavaScript global variable wgResourceLoaderStorageVersion is now
removed.

This change makes the JavaScript code smaller.

Change-Id: I8e31b95d4c44ba653bedb6be500011a39bc6abd8
2019-07-04 16:45:15 +00:00
Fomafix
bac0e0160f Remove JavaScript global variable wgLoadScript
Use
  mw.util.wikiScript( 'load' )
instead of
  mw.config.get( 'wgLoadScript' )

The module 'mediawiki.util' now gets the value from a private config
variable.

Change-Id: Iae4f4754f40999ba9d7c7161e9a37820c4b5931c
2019-07-03 06:01:25 +02:00
jenkins-bot
116b39f632 Merge "resourceloader: Remove support for raw modules" 2019-06-27 07:02:38 +00:00
Timo Tijhof
c554ee8e64 resourceloader: Remove support for raw modules
Being a raw module means that when it is requested from load.php with
"only=scripts" set, then the output is *not* wrapped in an
'mw.loader.implement' closure *and* there no 'mw.loader.state()' appendix.
Instead, it is served "raw".

Before 2018, the modules 'mediawiki' and 'jquery' were raw modules.
They were needed before the client could define 'mw.loader.implement', and
could never be valid dependencies. Module 'mediawiki' merged to 'startup',
and 'jquery' became a regular module (T192623). Based on the architecture
of modules being deliverable bundles, it doesn't make sense for there to
ever be raw modules again. Anything that 'startup' needs should be bundled
with it. Anything else is a regular module.

On top of that, we never actually needed this feature because specifying
the 'only=scripts' and 'raw=1' parameters does the same thing.

The only special bit about marking modules (not requests) as "raw" was that
it allowed the client to forget to specify "raw=1" and the server would
automatically omit the 'mw.loader.state()' appendix based on whether the
module is marked as raw. As of Ie4564ec8e26ad53f2, the two remaining use
cases for raw responses now specify the 'raw=1' request parameter, and we
can get rid of the "raw module" feature and all the complexity around it.

== Startup module

In the startup module there was an interesting use of isRaw() that has
little to do with the above. The "ATTENTION" warning there applies to the
startup module only, not raw modules in general. This is now fixed by
explicitly checking for StartupModule.

Above that warning, it talked about saving bytes, which was an optimisation
given that "raw" modules don't communicate with mw.loader, they also don't
need to be registered there because even if mw.loader would try to load
them, the server would never inform mw.loader about the module having
arrived. There are now no longer any such modules.

Bug: T201483
Change-Id: I8839036e7b2b76919b6cd3aa42ccfde4d1247899
2019-06-27 00:08:14 +00:00
Fomafix
d13e5b757b resourceloader: Set the request base parameters on server-side
This change also removes the defaults from the URL parameter:
* lang=qqx
* skin=fallback
* debug=false

Bug: T225899
Change-Id: I4cbc42e39ebc56c3d29f773a275afe2b1a44c913
2019-06-26 22:47:21 +00:00
jenkins-bot
fe10ea53f7 Merge "resourceloader: Remove redundant 'group' setting for StartupModule" 2019-06-19 12:26:04 +00:00
jenkins-bot
fe276bb080 Merge "resourceloader: Ignore coverage for getBaseModulesInternal() wrapper" 2019-06-19 11:20:31 +00:00
Timo Tijhof
5c89c27276 resourceloader: Ignore coverage for getBaseModulesInternal() wrapper
The getBaseModules() method is covered already.

Change-Id: I92d9063b72cee9e3be7329927bf5b97028399c14
2019-06-18 20:28:39 +00:00
Timo Tijhof
95985d0e49 resourceloader: Remove redundant 'group' setting for StartupModule
This feaure exists for controlling cache fragmentation of modules
that are queued for loading. However, the startup module is never
"queued" for loading.

It's loading is hardwired into ResourceLoaderClientHtml and doesn't
use any batching and couldn't logically, given that by design it
has to be the first thing that loads and cannot be combined with
other code (because we need to be able to return early and control
what else gets loaded from there).

[0] https://www.mediawiki.org/wiki/ResourceLoader/Architecture#Balance

Change-Id: If8900c538ce623f6a9a68a3bbef0927b4b6ae346
2019-06-14 15:46:10 +01:00
Timo Tijhof
14547fd9dc resourceloader: Skip modules with circular deps in tree optimiser
Either the server needs to omit these from the registry with
state=error output to the client (and server-side error logging),
or it needs to detect them, and transport them unchanged, so that
the existing client-side logic can handle it.

This patch does the latter.

Without the source code change in this patch, the added test case
fails due to "top" and "middle1" then being registered with
an empty array as dependencies.

Bug: T223402
Change-Id: I57502d7c4e434de4737759aed325dd4200ca89bf
2019-06-13 20:11:44 +00:00
Timo Tijhof
3656607b7d resourceloader: Deprecate ResourceLoaderContext::getConfig and ::getLogger
The methods existed for two use cases.

1. Inside ResourceLoaderContext, usage was removed with I4e4ee758cd22.
2. In Module class methods that get $context, already have their own
   Config and Logger instances injected from ResourceLoader::getModule(),
   which should be used instead.

Deprecating these opens the paths for making ResourceLoaderContext
a purer value object with no ResourceLoader, Config, or Logger objects
needing to be passed (in the future).

Bug: T32956
Change-Id: I74a9535918ea43b2c00073c5d4469f864d1eeb41
2019-06-13 18:28:58 +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
Derick Alangi
1981823755 Remove several methods, deprecated in 1.32
I've checked and doubled checked that these methods are no longer used
anywhere in core or extensions, hence removed them. They were hard deprecated
in MediaWiki 1.32.

* OutputPage:
  ** `::showFileCopyError()`
  ** `::showFileRenameError()`
  ** `::showFileDeleteError()`
  ** `::showFileNotFoundError()`

* ApiBase:
  ** `::truncateArray()`

* IcuCollation:
  ** `::getICUVersion()`

* HTMLForm:
  ** `::setSubmitProgressive()`

* ResourceLoaderStartUpModules:
  ** `::getStartupModules()`
  ** `::getLegacyModules()`

* BaseTemplate:
  ** `::msgHtml()`

* QuickTemplate:
  ** `::msgHtml()`

* WatchAction:
  ** `::getUnwatchToken()`

Bug: T220656
Change-Id: Ic1a723a991f4ff63fcb5f045ddcda18d1f8c3c68
2019-05-09 11:36:44 -07:00
Aryeh Gregor
2e1ac38485 Mass conversion to NamespaceInfo
Change-Id: I2fef157ceec772f304c0923a1cd8c0eef2e82a0f
2019-05-07 22:44:56 +02:00
Timo Tijhof
f831b28d16 resourceloader: Remove 'wgMainPageTitle' mw.config key
This was added in 2009 with cf75bdf4ba (r54384) and moved to the
startup module in 2010 with a99f9ec28b (r72772).

It is no longer used by any extension in Wikimedia Git, nor
elsewhere indexed by MediaWiki Codesearch. It also no longer has
any uses in mwgrep from public WMF wikis.

Bug: T220926
Depends-On: Ifdedccb513f5dd4636a37badc329ac5f1c4dd943
Change-Id: Id2729653cd450d31c1d903358ccf5e4fac564228
2019-04-15 19:04:49 +01:00
Timo Tijhof
821505367e title: Allow passing MessageLocalizer to newMainPage()
The method could not be used in session-less endpoints. This was
worked around once in the Startup module.

I plan to use this method in an extension module as well,
and would prefer not to duplicate core's logic for determining
the main page, outside this repository.

As general dependency-injection pattern, it seems desirable
to allow injecting a MessageLocalizer here.

Change-Id: I76cd02b2f489882e9404b93270f76aad9f0a4d9d
2019-04-14 03:26:17 +01:00
Timo Tijhof
249c9d631a resourceloader: Remove wgAvailableSkins from mw.config
Added in 2011 for use in QUnit tests (r80790, r80792).

That was a terrible idea in hindsight, which I removed again in
2015 with 6b758fc982, and 0f9e4ca0fb.

If a need for it were to arise in the future, we'd export it
within the file module that needs it, or via addJsConfigVars()
on only the pages that need it – not globally.

Bug: T217772
Change-Id: I3885cacaa9b33e6947dbaf26f9b6839e19588603
2019-03-06 19:55:42 +00:00
Timo Tijhof
194bdc09a8 resourceloader: Remove ResourceLoaderMaxQueryLength from mw.config
This is only used internally. It doesn't need to be exported
as part of mw.config.

Change-Id: If4206d797b5d426eb999c34ad5dde3ba141c6f05
2019-03-06 15:57:56 +00:00
Timo Tijhof
1476e9994b resourceloader: Use local var for getConfig() calls in StartUpModule
Change-Id: I53af241454872fd228869b45dc74175c56026d6e
2019-03-06 15:45:55 +00:00
Brad Jorsch
0abb9338f8 Mostly drop old comment schemas
This removes most of the pre-CommentStore text columns, and the
$wgCommentTableSchemaMigrationStage setting that used to determine
whether the columns were used.

rev_comment remains in the code, as on Wikimedia wikis the revision
table is too large to alter at this time. A future change will combine
that with the removal of rev_user_text, rev_content_model, and
rev_content_format (and the addition of rev_comment_id and rev_actor).

CommentStore's constructor continues to take a $stage parameter, and
continues to have the logic for handling it, for the benefit of
extensions that might need their own migration process.

Bug: T166733
Change-Id: I1479c73774e01ead1490adf6128f820c09bce9d4
2019-02-07 16:59:27 +11:00
jdlrobson
7356e66e28 resourceloader: ResourceLoaderGetConfigVars is passed skin
The startup module varies by skin, so it should be possible for
consumers of the ResourceLoaderGetConfigVars hook to know what
skin it being requested.

Bug: T186062
Change-Id: I97d6b4bc245bc64ff148c3665b46116b8a6be409
2018-10-22 18:55:44 +00:00
Timo Tijhof
b7f4b55f2b resourceloader: Factor out encodeJsonForScript
Follows-up dc3fc6cf81, which documented the reasoning for the
specific json flags in StartupModule. In wanting to re-use them
in a different module it became apparant that perhaps it was a
bit too conservative in only allowing the flags to be used in
a script HTTP response.

Lax the contract a little bit (that is, do more escaping) to also
allow safe re-use in HTML context.

I considered making these separate methods (e.g. forScriptResponse,
and forInlineScript) but decided not to because the vast majority
of callers would have to be forInlineScript eventhough the code
in question had no responsiblity or knowledge of it becoming an
inline script, because ResourceLoader allows most modules to
become embedded if they support a private or preview mode.

Those modes are implemented by calling makeModuleResponse, and
wrapping it an inline script. It seems appealing and simplifying
to the API to require that script output is always safe for
embedding rather than complicating the API for winning back
a literal handful of bytes in the edge case that a user-generated
string contains a '<' and was not embedded. I estimate that with
gzip, it will literally save only a single byte, even if used
multiple times. Let's focus optimisation efforts elsewhere :)

Change-Id: I7742dabba6750deecf6fbf51cf9a77ee8cbfc727
2018-09-18 00:53:42 +01:00
Timo Tijhof
b70ab40839 resourceloader: Use 'enableModuleContentVersion' for startup module
This significantly simplifies the getVersionHash implementation for
StartupModule, and fixes a couple of bugs.

Previously, the startup module's E-Tag was determined by the
'getDefinitionSummary' method, which combined the E-Tag values
from all registered modules, plus what we thought is all information
used by 'getScript' (config vars, embedded script files, list
of base modules, ...)

However, this were various things part of the manifest that it
forgot about, including:

* Changes to the list of dependencies of a module.
* Changes to the name of module.
* Changes to the cache group of module.
* Adding or removing a foreign module source (mw.loader.addSource).

These are all quite rare, and when they do change, they usually
also involve a change that *was* tracked already. But, sometimes
they don't and that's when bugs happened.

Instead of the tracking array of getDefinitionSummary, we now
use the 'enableModuleContentVersion' option for StartupModule,
which simply calls the actual getScript() method and hashes that.

Of note: When an exception happens with the version computation of
any individual module, we catch it, log it, and continue with the
rest. Previously, the first time such error was discovered at
run-time would be in the getCombinedVersion() call from
StartupModule::getAllModuleHashes(). That public getCombinedVersion()
method of ResourceLoader had the benefit of also outputting details
of that exception in the HTTP response output. In order to keep that
behaviour, I made outputErrorAndLog() public so that StartupModule
can call it directly now. This is covered by
ResourceLoaderTest::testMakeModuleResponseStartupError.

Bug: T201686
Change-Id: I8e8d3a2cd2ccd68d2d78e988bcdd0d77fbcbf1d4
2018-08-31 00:23:23 +00:00
Timo Tijhof
dc3fc6cf81 resourceloader: Audit use of JSON encoding and use json_encode directly
* Remove use of MediaWiki's FormatJson class. Ref T32956.

* FormatJson::decode() was a direct alias of json_decode.

* FormatJson::encode() is a wrapper for json_encode that
  sets `JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP`
  by default, plus a boolean parameter to add JSON_PRETTY_PRINT.

  Instead, use json_encode() directly. By default json_encode() escapes
  slashes and non-ASCII unicode.

* Audit our uses of JSON encoding, document their needs, and set flags
  as needed.

* Remove $mapToJson abstraction from ResourceLoaderStartUpModule.

* Always pretty-print the list of module names in the error message,
  regardless of debug mode.

* Remove hacky indentation-adder from ResourceLoaderStartUpModule.
  This was relying on there not being line breaks in the json output
  outside debug mode, and adding a level of indentation to roughly
  match the code in the JSON is substituted. This didn't match and
  just generally doesn't seem worth it.

Change-Id: I3e09ddeb4d53c8980195c1855303c0ee25bd4c20
2018-08-29 00:46:11 +00:00
Timo Tijhof
7f3c102a3b resourceloader: Implement mw.inspect 'time' report
When enabling $wgResourceLoaderEnableJSProfiler, mw.loader gets instrumented
with the following timing values for each of the modules loaded on the page:

* 'total' - This measures the time spent in mw.loader#execute(), and
  represents the initialisation of the module's implementation, including
  the registration of messages, templates, and the execution of the 'script'
  closure received from load.php.

* 'script' – This measures only the subset of time spent in the internal
  runScript() function, and represents just the execution of the module's
  JavaScript code as received through mw.loader.implement() from load.php.

  For user scripts and site scripts, this measures the call to domEval
  (formerly known as "globalEval").

* 'execute' - This measures the self time of mw.loader#execute(), which is
  effectively `total - script`.

To view the report, enable the feature, then run `mw.inspect( 'time' )` from
the browser console, which will render a table with the initialisation
overhead from each module used on the page.

Bug: T133646
Change-Id: I68d1193b62c93c97cf09b7d344c896afb437c5ac
2018-08-23 10:54:55 -07:00
Aryeh Gregor
90d4f56fe4 Mass conversion of $wgContLang to service
Brought to you by vim macros.

Bug: T200246
Change-Id: I79e919f4553e3bd3eb714073fed7a43051b4fb2a
2018-08-11 22:44:29 -06:00