Add a hook to StartUpModule that can modify the source URLs
that get embedded into the startup module JS in the form of
mw.loader.addSource() parameters.
The intended use case is preserving relevant URL information,
especially in the case of the 'local' source which is a
relative URL, when the URL pattern of the load.php URL
that generates the startup module code is different from the
URL pattern of the page that loads that load.php URL.
(E.g. $wgLoadScript is set to a different domain than the
current page, to canonicalize load.php URLs for a site
that's reachable via multiple domains, but then by default
the local source is a relative URL which would be
interpreted relative to the URL of the page that executes
the startup module code, so it would result in calls to
non-canonical load.php URLs).
Bug: T365162
Bug: T371530
Change-Id: I199ab779abd0596b836ae43dcc5f2f2a489c9274
Follows-up I0191a812f044a5c04c:
* $installedSkins was named after MediaWiki's SkinFactory and its
return value was not a list of skins, or actually a registry
of skin names and PHP classes (subclasses of "Skin"). This
information is of no use to ResourceLoader as it cannot construct
skin objects (skins would require an RequestContext such used on
index.php).
Change its format to an actual list, and rename to reflect its
local purpose.
* Simplify logic to: If not set, or, we do validation and the
value is not valid.
* Update docs to explain what "perform validation" means.
Change-Id: Ic8544d99055a7b7c7e55496006b5971e4e4fa14f
RL\Context::class depends on SkinFactory to get the installed skins
to check if the skin from the URL is in the list of installed skins
or defaults to 'fallback'.
Most instantiators of RL\Context already have a fallback skin specified
so instead of relying on SkinFactory in the constructor of Context,
let's get the list of installed skins in RL entry point and pass that
instead.
In tests, OutputPage, etc, they're all using a fake request which will
eventually default to the 'fallback' or 'apioutput' or related skin.
NOTE: In ContextTest.php, adjust callers of ::getResourceLoader() to
use `self` instead of `$this` since it's defined as a static method.
Bug: T32956
Change-Id: I0191a812f044a5c04c50c62163395c4a706c375c
The feature would be opt in to retain backwards compatible
support while also moving closer to rendering icons
consistently with how Codex does.
An example of this in use are:
* Ie5c88e0aa243f73f2dc9f310d18fd59b831edc64
* I17fabdf276f6c33fb78c007d75cda6bb9e02d79b
Bug: T365764
Bug: T358246
Change-Id: I95caab8037ccceba73101da2eb3c601f39511377
I believe this makes the code less brittle, and also makes it a bit
more obvious what these strings are meant to represent.
Change-Id: Ia39b5c80af4b495931d0a68fd091b783645dd709
And deprecated aliases for the the no namespaced classes.
ReplicatedBagOStuff that already is deprecated isn't moved.
Bug: T353458
Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
Changes to the use statements done automatically via script
Addition of missing use statement done manually
Change-Id: Iae45fa269363be8ee05c598ea6926514ce817762
This patch introduces a namespace declaration for the
MediaWiki\Content to CssContent and establishes a class
alias marked as deprecated since version 1.43.
Bug: T353458
Change-Id: I6ab25787893cb2195f8cd2ba125ed8dd5a60de43
This patch introduces a namespace declaration for the
MediaWiki\Content to JavaScriptContentHandler and establishes a class
alias marked as deprecated since version 1.43.
Bug: T353458
Change-Id: Ic30789d4e80a27004b6bc3b3ba891a7332a5e1ba
This patch introduces a namespace declaration for the
MediaWiki\Content to JavaScriptContent and establishes a class
alias marked as deprecated since version 1.43.
Bug: T353458
Change-Id: I87c17327911e28a461feaf2ff46242454cff257a
CODEX_MODULE_DIR is always the /modules subdirectory of
CODEX_LIBRARY_DIR, so remove it and derive it that way instead.
- Update tests accordingly
- Rename test data files accordingly
- Use CODEX_LIBRARY_DIR in one place where we had neglected to use a
constant
Change-Id: Ieb347c2d128f3addfb11f6aca79d63969434f342
Remove a bunch of mocking complexity in favour of real pages.
This is in prep for making a better regression test in change
I591ee186083f for T360014.
Bug: T360014
Change-Id: I2f99a542a6d17a8503213f68c3df6a1c5ca50c77
Use TitleValue instead of Title::newFromText to reduce complexity of
this test.
Change `Project:Example/foo.js` example to NS_USER to be more
realistic, given that (afaik) there can't be a WikiModule with a
page in NS_PROJECT. It is true that people sometimes import project
pages containing JS via importScript over action=raw, but that
doesn't involve ResourceLoader.
Change-Id: Id2df9a0f17880e397b02d4c855d9e0287a8949ee
* Remove references to IDatabase from preloadModuleInfo() and with
it the last reference to Rdbms in the ResourceLoader service
(progressing T32956).
* Simplify WikiModule::preloadTitleInfo() so that it doesn't need
an IDatabase object unless
1) there are non-zero WikiModule objects in the batch, and
2) there is a cache miss.
* Remove needless IDatabase parameters passed or mocked for this
method. Note that WikiModule already had `@group Database` set
since each WikiModule::getDB() is called and uses an unmocked
database. The mocked database was only injected to satisfy the
method signature.
Bug: T32956
Bug: T359522
Change-Id: I022f02d6e6bbae46c3258a7c07a1d6723506d8bc
Fixed SkinModuleTest::provideGetFeatureFilePathsOrder as nesting of
arrays for parameters is wrong
Change-Id: I9875008adf62d284c48662ebfbd245d72e5be064
Changes SkinModule::getStyles to output config features
first, then skin customization styles last. This requires
using the ResourceLoader::makeCombinedStyles method to
first combine feature styles, then combine style related styles,
and return the concatenated result in SkinModule::getStyles().
The resulting stylesheet ordering is changed so that all
skin customization styles are always output after core styles,
which allows skins to override core-styles via cascade order instead
of increased specificity.
Previous output order:
- all (core+custom)
- print (core+custom)
- screen (core+custom)
- other custom
New output order:
- all (core)
- print (core)
- screen (core)
- other (core)
- all (custom)
- print (custom)
- screen (custom)
- other (custom)
SkinModule is refactored to separate logo-related style
generation, as well as skin feature generation, in order to maintain
testability. Tests are also refactored to better cover different
skin feature configurations.
Bug: T354975
Change-Id: I261742c0ae4c3d57353bf1854af66f39df6132f7
expectWarning() and friends have been deprecated in PHPUnit 9.6, and
removed in PHPUnit 10. Unfortunately, there is no simple replacement
because PHPUnit no longer converts them to exceptions in the first
place. In fact, Sebastian Bergmann explicitly stated that he does not
consider the use case of
> a library developer to verify a code block warns its consumer when
> certain action is performed
worth supporting.
So, add an ad-hoc replacement for all the deprecated methods. This is
quite ugly, but it's simple enough given the low number of usages.
On the bright side, this new method does not halt the test when the
warning is triggered. This seems to align with the developers'
expectation, seen in a few existing tests, that any code following the
notice will be executed.
Bug: T342110
Change-Id: I214abfed4280834840c115777ed78eb0a5570da9
Follows-up Iadea44b7867f48a2be6ccbf00c0e56911a5af74e.
ResourceLoaderEntryPoint:
* Rename from Resource to ResourceLoader, as it is the entry point
for ResourceLoader.
* Fix accidental use of ingroup on the file docblock
instead of the class.
https://phabricator.wikimedia.org/F42046908
* Fix broken "see" reference to "/load.php" on the ResourceEntryPoint
class on doc.wikimedia.org. Files are indexed in Doxygen by full
name without leading slash.
* Remove load.php from docgroup, akin to index.php.
tests:
* Remove unrelated Rest namespace from test suite.
* Remove redundant default values in newResourceLoader(),
especially null values were confusing by showing an
apparent intent to set a value without actually
isplacing the default, given that isset/?? treat
set null as not set.
* Simplify test by using the built-in startup module instead.
EntryPoint:
* Remove comment in test about doPostOutputShutdown.
It sounded like it was explaining that we use getCapturedOutput()
instead of run() because the latter calls doPostOutputShutdown
which we want to avoid. Except, we don't avoid it,
since run() is called and does call doPostOutputShutdown.
Unclear what it was explaining.
* Improve docs around getCapturedOutput() in the base class,
and make explicit that this seemingly unused complexity
exists for the purpose of testing.
Bug: T354216
Change-Id: I5139fda90a3d5ac7ea1ed917c8045d1a09961d78
This reverts commit afdc92987f.
Also reverts Ib44687b which was a follow-up.
Reason for revert: Caused T357929
Bug: T357929
Bug: T354975
Change-Id: Ic6d0b472cc2b26cb7c375bf9a5d2e03a4d6c6a18
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
Reorders ResourceLoader\\SkinModule style output so that all styles
produced by skins are output after styles that are produces by
skin "features" such as normalize.
Refactors & expands SkinModuleTest.php to include tests for default
values, print styles and correct style ordering.
Bug: T354975
Change-Id: I0000b4ad8eb2de40be293f0e693d873c282ea785
This improves handling of edge cases around flushing buffers:
- Distingush clearly between "headers sent" and "all output sent"
states.
- Warn when trying to flush output after output was already sent to the
client.
- Avoid looping indefinitely when failing to delete a buffer, to work
around a quirk of PHP's zlib.compression buffer.
Follow-up: I4ea116d60030da92be14f0283ce4dc4877c4ca13
Bug: T356578
Change-Id: Iaf34a48b89e969b8e26328f0d2512ad22ef48212
- Add a getCodexFiles() method that parses the manifest and transforms
it to a more useful format based on actual file names rather than
manifest keys
- Cache the result as a static class property, so that it's reused
between all CodexModule instances
- Use the resulting data structure to simplify the rest of the code
- This also has the side effect of correctly throwing an error when a
nonexistent file is requested (this wasn't the case before). Add a
test case for this.
- Add a test for this new method in CodexModuleTest.php
Change-Id: Id527cef0e19fec7b54af3bf65a1de66f50d5fff0
* $statName should be set, and was/is unconditionally used as a string.
The added `?: 'na'` appears not to be needed.
Follows-up Ida57415073 (1204f0dee4).
* Fix lazy setName() calls in tests to actually pass a valid non-empty
string, like other tests do. Follows-up I1c03e3f470 (3a9744921d).
Change-Id: I1c8cd7d8c043845c0373a457b389213e5111976b
The idea is that all entry points should share the code in the
MediaWikiEntryPoint base class. This change by itself doesn't achieve much, it should be followed up by a change moving request handling logic from ResourceLoader into ResourceEntryPoint.
Bug: T354216
Change-Id: Iadea44b7867f48a2be6ccbf00c0e56911a5af74e
This patch adds test cases for the following scenarios:
- codexComponents defined as an empty array in the module definition
file
- codexComponents defined as a non-array type in the module definition
file
Bug: T353858
Change-Id: I055f837baab2bfce5ae840a472a9f8a2bf3847df
CodexModule throws an InvalidArgumentException if one of the elements
of the codexComponents array refers to a private chunk rather than a
public entry point file. Add a unit test asserting this behavior.
Also add an `isset()` to the check in CodexModule so that it doesn't
cause a PHP notice about a missing array index.
Bug: T353191
Change-Id: I3e31511aeeb42d825c308f047894f5eba28b0f27
It has been deprecated since 1.35, hard deprecated since at least I9776d11d4e2d184
No grep result in wmf-config
Change-Id: I2c67bab3e3212f25a0cbce7301f5e32a082f76da
If a generated chunk is listed in the codexComponents array,
an exception will be thrown informing the developer that the
item is not an export of Codex and cannot be required.
Text fixtures and expected values were updated to match
recent changes to the manifest that made composables
explict entries.
Bug: T353191
Change-Id: Ie3e35501993b1ad5d29ebecbcc8203e7f4ea8c81
This patch adds a test case for the scenario where a codex component is
not defined in the module definition file and a user attempts to require
it.
The scenario where the 'codexComponents' key is defined but is an empty
array will be tested separately after 984663 lands.
Bug: T353858
Change-Id: I717ac327848ff6f6baad83110e8d2f10c135e5f1
This adds support for ES6 and ES7 syntax to user scripts, thus
matching the wikimedia/minify library.
Bug: T75714
Depends-On: I43d4619a32e37eb42e1aaa55a1f602962609c52b
Depends-On: If3b2b4a75013baeaa0d9b92cd10dfb06e5534153
Change-Id: Ie309e761f8b20640f7c0e85def0a3d1ccc8a658e