2014-03-07 18:29:23 +00:00
|
|
|
<?php
|
|
|
|
|
|
2022-05-06 09:09:56 +00:00
|
|
|
namespace MediaWiki\Tests\ResourceLoader;
|
|
|
|
|
|
|
|
|
|
use Exception;
|
|
|
|
|
use MediaWiki\ResourceLoader\Module;
|
|
|
|
|
use MediaWiki\ResourceLoader\StartUpModule;
|
|
|
|
|
use ResourceLoaderStartUpModule;
|
|
|
|
|
use ResourceLoaderTestCase;
|
|
|
|
|
use ResourceLoaderTestModule;
|
|
|
|
|
|
|
|
|
|
class StartUpModuleTest extends ResourceLoaderTestCase {
|
2014-03-07 18:29:23 +00:00
|
|
|
|
2015-11-17 04:22:15 +00:00
|
|
|
protected static function expandPlaceholders( $text ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
return strtr( $text, [
|
2016-09-12 20:52:10 +00:00
|
|
|
'{blankVer}' => self::BLANK_VERSION
|
2016-02-17 09:09:32 +00:00
|
|
|
] );
|
2015-11-17 04:22:15 +00:00
|
|
|
}
|
|
|
|
|
|
2017-04-06 01:19:48 +00:00
|
|
|
public function provideGetModuleRegistrations() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
|
|
|
|
[ [
|
2014-03-07 18:29:23 +00:00
|
|
|
'msg' => 'Empty registry',
|
2016-02-17 09:09:32 +00:00
|
|
|
'modules' => [],
|
2014-03-07 18:29:23 +00:00
|
|
|
'out' => '
|
2019-07-16 00:15:32 +00:00
|
|
|
mw.loader.addSource({
|
2014-08-25 08:02:48 +00:00
|
|
|
"local": "/w/load.php"
|
2019-07-16 00:15:32 +00:00
|
|
|
});
|
|
|
|
|
mw.loader.register([]);'
|
2016-02-17 09:09:32 +00:00
|
|
|
] ],
|
|
|
|
|
[ [
|
2014-03-07 18:29:23 +00:00
|
|
|
'msg' => 'Basic registry',
|
2016-02-17 09:09:32 +00:00
|
|
|
'modules' => [
|
2019-07-11 19:48:57 +00:00
|
|
|
'test.blank' => [ 'class' => ResourceLoaderTestModule::class ],
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2014-03-07 18:29:23 +00:00
|
|
|
'out' => '
|
2019-07-16 00:15:32 +00:00
|
|
|
mw.loader.addSource({
|
2014-08-25 08:02:48 +00:00
|
|
|
"local": "/w/load.php"
|
2019-07-16 00:15:32 +00:00
|
|
|
});
|
|
|
|
|
mw.loader.register([
|
2014-03-07 18:29:23 +00:00
|
|
|
[
|
|
|
|
|
"test.blank",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
""
|
2014-03-07 18:29:23 +00:00
|
|
|
]
|
2019-07-16 00:15:32 +00:00
|
|
|
]);',
|
2019-05-22 18:29:09 +00:00
|
|
|
] ],
|
|
|
|
|
[ [
|
|
|
|
|
'msg' => 'Optimise the dependency tree (basic case)',
|
|
|
|
|
'modules' => [
|
2019-07-11 19:48:57 +00:00
|
|
|
'a' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'dependencies' => [ 'b', 'c', 'd' ],
|
|
|
|
|
],
|
|
|
|
|
'b' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'dependencies' => [ 'c' ],
|
|
|
|
|
],
|
|
|
|
|
'c' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'dependencies' => [],
|
|
|
|
|
],
|
|
|
|
|
'd' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'dependencies' => [],
|
|
|
|
|
],
|
2019-05-22 18:29:09 +00:00
|
|
|
],
|
|
|
|
|
'out' => '
|
2019-07-16 00:15:32 +00:00
|
|
|
mw.loader.addSource({
|
2019-05-22 18:29:09 +00:00
|
|
|
"local": "/w/load.php"
|
2019-07-16 00:15:32 +00:00
|
|
|
});
|
|
|
|
|
mw.loader.register([
|
2019-05-22 18:29:09 +00:00
|
|
|
[
|
|
|
|
|
"a",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2019-05-22 18:29:09 +00:00
|
|
|
[
|
|
|
|
|
1,
|
|
|
|
|
3
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"b",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2019-05-22 18:29:09 +00:00
|
|
|
[
|
|
|
|
|
2
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"c",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
""
|
2019-05-22 18:29:09 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"d",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
""
|
2019-05-22 18:29:09 +00:00
|
|
|
]
|
2019-07-16 00:15:32 +00:00
|
|
|
]);',
|
2019-05-22 18:29:09 +00:00
|
|
|
] ],
|
|
|
|
|
[ [
|
|
|
|
|
'msg' => 'Optimise the dependency tree (tolerate unknown deps)',
|
|
|
|
|
'modules' => [
|
2019-07-11 19:48:57 +00:00
|
|
|
'a' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'dependencies' => [ 'b', 'c', 'x' ]
|
|
|
|
|
],
|
|
|
|
|
'b' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'dependencies' => [ 'c', 'x' ]
|
|
|
|
|
],
|
|
|
|
|
'c' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'dependencies' => []
|
|
|
|
|
],
|
2019-05-22 18:29:09 +00:00
|
|
|
],
|
|
|
|
|
'out' => '
|
2019-07-16 00:15:32 +00:00
|
|
|
mw.loader.addSource({
|
2019-05-22 18:29:09 +00:00
|
|
|
"local": "/w/load.php"
|
2019-07-16 00:15:32 +00:00
|
|
|
});
|
|
|
|
|
mw.loader.register([
|
2019-05-22 18:29:09 +00:00
|
|
|
[
|
|
|
|
|
"a",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2019-05-22 18:29:09 +00:00
|
|
|
[
|
|
|
|
|
1,
|
|
|
|
|
"x"
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"b",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2019-05-22 18:29:09 +00:00
|
|
|
[
|
|
|
|
|
2,
|
|
|
|
|
"x"
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"c",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
""
|
2019-05-22 18:29:09 +00:00
|
|
|
]
|
2019-07-16 00:15:32 +00:00
|
|
|
]);',
|
2019-05-22 18:29:32 +00:00
|
|
|
] ],
|
|
|
|
|
[ [
|
|
|
|
|
// Regression test for T223402.
|
|
|
|
|
'msg' => 'Optimise the dependency tree (indirect circular dependency)',
|
|
|
|
|
'modules' => [
|
2019-07-11 19:48:57 +00:00
|
|
|
'top' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'dependencies' => [ 'middle1', 'util' ],
|
|
|
|
|
],
|
|
|
|
|
'middle1' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'dependencies' => [ 'middle2', 'util' ],
|
|
|
|
|
],
|
|
|
|
|
'middle2' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'dependencies' => [ 'bottom' ],
|
|
|
|
|
],
|
|
|
|
|
'bottom' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'dependencies' => [ 'top' ],
|
|
|
|
|
],
|
|
|
|
|
'util' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'dependencies' => [],
|
|
|
|
|
],
|
2019-05-22 18:29:32 +00:00
|
|
|
],
|
|
|
|
|
'out' => '
|
2019-07-16 00:15:32 +00:00
|
|
|
mw.loader.addSource({
|
2019-05-22 18:29:32 +00:00
|
|
|
"local": "/w/load.php"
|
2019-07-16 00:15:32 +00:00
|
|
|
});
|
|
|
|
|
mw.loader.register([
|
2019-05-22 18:29:32 +00:00
|
|
|
[
|
|
|
|
|
"top",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2019-05-22 18:29:32 +00:00
|
|
|
[
|
|
|
|
|
1,
|
|
|
|
|
4
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"middle1",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2019-05-22 18:29:32 +00:00
|
|
|
[
|
|
|
|
|
2,
|
|
|
|
|
4
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"middle2",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2019-05-22 18:29:32 +00:00
|
|
|
[
|
|
|
|
|
3
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"bottom",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2019-05-22 18:29:32 +00:00
|
|
|
[
|
|
|
|
|
0
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"util",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
""
|
2019-05-22 18:29:32 +00:00
|
|
|
]
|
2019-07-16 00:15:32 +00:00
|
|
|
]);',
|
2019-05-22 18:29:32 +00:00
|
|
|
] ],
|
|
|
|
|
[ [
|
|
|
|
|
// Regression test for T223402.
|
|
|
|
|
'msg' => 'Optimise the dependency tree (direct circular dependency)',
|
|
|
|
|
'modules' => [
|
2019-07-11 19:48:57 +00:00
|
|
|
'top' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'dependencies' => [ 'util', 'top' ],
|
|
|
|
|
],
|
|
|
|
|
'util' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'dependencies' => [],
|
|
|
|
|
],
|
2019-05-22 18:29:32 +00:00
|
|
|
],
|
|
|
|
|
'out' => '
|
2019-07-16 00:15:32 +00:00
|
|
|
mw.loader.addSource({
|
2019-05-22 18:29:32 +00:00
|
|
|
"local": "/w/load.php"
|
2019-07-16 00:15:32 +00:00
|
|
|
});
|
|
|
|
|
mw.loader.register([
|
2019-05-22 18:29:32 +00:00
|
|
|
[
|
|
|
|
|
"top",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2019-05-22 18:29:32 +00:00
|
|
|
[
|
|
|
|
|
1,
|
|
|
|
|
0
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"util",
|
2017-04-06 01:19:48 +00:00
|
|
|
""
|
|
|
|
|
]
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
]);',
|
2016-02-17 09:09:32 +00:00
|
|
|
] ],
|
|
|
|
|
[ [
|
2014-03-07 18:29:23 +00:00
|
|
|
'msg' => 'Group signature',
|
2016-02-17 09:09:32 +00:00
|
|
|
'modules' => [
|
2019-07-11 19:48:57 +00:00
|
|
|
'test.blank' => [ 'class' => ResourceLoaderTestModule::class ],
|
|
|
|
|
'test.group.foo' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'group' => 'x-foo',
|
|
|
|
|
],
|
|
|
|
|
'test.group.bar' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'group' => 'x-bar',
|
|
|
|
|
],
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2014-03-07 18:29:23 +00:00
|
|
|
'out' => '
|
2019-07-16 00:15:32 +00:00
|
|
|
mw.loader.addSource({
|
2014-08-25 08:02:48 +00:00
|
|
|
"local": "/w/load.php"
|
2019-07-16 00:15:32 +00:00
|
|
|
});
|
|
|
|
|
mw.loader.register([
|
2014-03-07 18:29:23 +00:00
|
|
|
[
|
|
|
|
|
"test.blank",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
""
|
2014-03-07 18:29:23 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.group.foo",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2014-03-07 18:29:23 +00:00
|
|
|
[],
|
2019-08-14 19:39:01 +00:00
|
|
|
2
|
2014-03-07 18:29:23 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.group.bar",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2014-03-07 18:29:23 +00:00
|
|
|
[],
|
2019-08-14 19:39:01 +00:00
|
|
|
3
|
2014-03-07 18:29:23 +00:00
|
|
|
]
|
2019-07-16 00:15:32 +00:00
|
|
|
]);'
|
2016-02-17 09:09:32 +00:00
|
|
|
] ],
|
|
|
|
|
[ [
|
2014-03-07 18:29:23 +00:00
|
|
|
'msg' => 'Different target (non-test should not be registered)',
|
2016-02-17 09:09:32 +00:00
|
|
|
'modules' => [
|
2019-07-11 19:48:57 +00:00
|
|
|
'test.blank' => [ 'class' => ResourceLoaderTestModule::class ],
|
|
|
|
|
'test.target.foo' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'targets' => [ 'x-foo' ],
|
|
|
|
|
],
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2014-03-07 18:29:23 +00:00
|
|
|
'out' => '
|
2019-07-16 00:15:32 +00:00
|
|
|
mw.loader.addSource({
|
2014-08-25 08:02:48 +00:00
|
|
|
"local": "/w/load.php"
|
2019-07-16 00:15:32 +00:00
|
|
|
});
|
|
|
|
|
mw.loader.register([
|
2014-03-07 18:29:23 +00:00
|
|
|
[
|
|
|
|
|
"test.blank",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
""
|
2014-03-07 18:29:23 +00:00
|
|
|
]
|
2021-12-24 19:32:14 +00:00
|
|
|
]);'
|
|
|
|
|
] ],
|
|
|
|
|
[ [
|
|
|
|
|
'msg' => 'Different skin (irrelevant skin modules should not be registered)',
|
|
|
|
|
'modules' => [
|
|
|
|
|
'test.blank' => [ 'class' => ResourceLoaderTestModule::class ],
|
|
|
|
|
'test.skin.fallback' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'skins' => [ 'fallback' ],
|
|
|
|
|
],
|
|
|
|
|
'test.skin.foo' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'skins' => [ 'foo' ],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'out' => '
|
|
|
|
|
mw.loader.addSource({
|
|
|
|
|
"local": "/w/load.php"
|
|
|
|
|
});
|
|
|
|
|
mw.loader.register([
|
|
|
|
|
[
|
|
|
|
|
"test.blank",
|
|
|
|
|
""
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.skin.fallback",
|
|
|
|
|
""
|
|
|
|
|
]
|
2019-07-16 00:15:32 +00:00
|
|
|
]);'
|
2018-03-28 00:57:06 +00:00
|
|
|
] ],
|
|
|
|
|
[ [
|
|
|
|
|
'msg' => 'Safemode disabled (default; register all modules)',
|
|
|
|
|
'modules' => [
|
|
|
|
|
// Default origin: ORIGIN_CORE_SITEWIDE
|
2019-07-11 19:48:57 +00:00
|
|
|
'test.blank' => [ 'class' => ResourceLoaderTestModule::class ],
|
|
|
|
|
'test.core-generated' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
2022-05-06 09:09:56 +00:00
|
|
|
'origin' => Module::ORIGIN_CORE_INDIVIDUAL
|
2019-07-11 19:48:57 +00:00
|
|
|
],
|
|
|
|
|
'test.sitewide' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
2022-05-06 09:09:56 +00:00
|
|
|
'origin' => Module::ORIGIN_USER_SITEWIDE
|
2019-07-11 19:48:57 +00:00
|
|
|
],
|
|
|
|
|
'test.user' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
2022-05-06 09:09:56 +00:00
|
|
|
'origin' => Module::ORIGIN_USER_INDIVIDUAL
|
2019-07-11 19:48:57 +00:00
|
|
|
],
|
2018-03-28 00:57:06 +00:00
|
|
|
],
|
|
|
|
|
'out' => '
|
2019-07-16 00:15:32 +00:00
|
|
|
mw.loader.addSource({
|
2018-03-28 00:57:06 +00:00
|
|
|
"local": "/w/load.php"
|
2019-07-16 00:15:32 +00:00
|
|
|
});
|
|
|
|
|
mw.loader.register([
|
2018-03-28 00:57:06 +00:00
|
|
|
[
|
|
|
|
|
"test.blank",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
""
|
2018-03-28 00:57:06 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.core-generated",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
""
|
2018-03-28 00:57:06 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.sitewide",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
""
|
2018-03-28 00:57:06 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.user",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
""
|
2018-03-28 00:57:06 +00:00
|
|
|
]
|
2019-07-16 00:15:32 +00:00
|
|
|
]);'
|
2018-03-28 00:57:06 +00:00
|
|
|
] ],
|
|
|
|
|
[ [
|
|
|
|
|
'msg' => 'Safemode enabled (filter modules with user/site origin)',
|
|
|
|
|
'extraQuery' => [ 'safemode' => '1' ],
|
|
|
|
|
'modules' => [
|
|
|
|
|
// Default origin: ORIGIN_CORE_SITEWIDE
|
2019-07-11 19:48:57 +00:00
|
|
|
'test.blank' => [ 'class' => ResourceLoaderTestModule::class ],
|
|
|
|
|
'test.core-generated' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
2022-05-06 09:09:56 +00:00
|
|
|
'origin' => Module::ORIGIN_CORE_INDIVIDUAL
|
2019-07-11 19:48:57 +00:00
|
|
|
],
|
|
|
|
|
'test.sitewide' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
2022-05-06 09:09:56 +00:00
|
|
|
'origin' => Module::ORIGIN_USER_SITEWIDE
|
2019-07-11 19:48:57 +00:00
|
|
|
],
|
|
|
|
|
'test.user' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
2022-05-06 09:09:56 +00:00
|
|
|
'origin' => Module::ORIGIN_USER_INDIVIDUAL
|
2019-07-11 19:48:57 +00:00
|
|
|
],
|
2018-03-28 00:57:06 +00:00
|
|
|
],
|
|
|
|
|
'out' => '
|
2019-07-16 00:15:32 +00:00
|
|
|
mw.loader.addSource({
|
2018-03-28 00:57:06 +00:00
|
|
|
"local": "/w/load.php"
|
2019-07-16 00:15:32 +00:00
|
|
|
});
|
|
|
|
|
mw.loader.register([
|
2018-03-28 00:57:06 +00:00
|
|
|
[
|
|
|
|
|
"test.blank",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
""
|
2018-03-28 00:57:06 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.core-generated",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
""
|
2018-03-28 00:57:06 +00:00
|
|
|
]
|
2019-07-16 00:15:32 +00:00
|
|
|
]);'
|
2016-02-17 09:09:32 +00:00
|
|
|
] ],
|
|
|
|
|
[ [
|
2014-03-07 18:29:23 +00:00
|
|
|
'msg' => 'Foreign source',
|
2016-02-17 09:09:32 +00:00
|
|
|
'sources' => [
|
|
|
|
|
'example' => [
|
2014-03-07 18:29:23 +00:00
|
|
|
'loadScript' => 'http://example.org/w/load.php',
|
|
|
|
|
'apiScript' => 'http://example.org/w/api.php',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'modules' => [
|
2019-07-11 19:48:57 +00:00
|
|
|
'test.blank' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'source' => 'example'
|
|
|
|
|
],
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2014-03-07 18:29:23 +00:00
|
|
|
'out' => '
|
2019-07-16 00:15:32 +00:00
|
|
|
mw.loader.addSource({
|
2014-08-25 08:02:48 +00:00
|
|
|
"local": "/w/load.php",
|
|
|
|
|
"example": "http://example.org/w/load.php"
|
2019-07-16 00:15:32 +00:00
|
|
|
});
|
|
|
|
|
mw.loader.register([
|
2014-03-07 18:29:23 +00:00
|
|
|
[
|
|
|
|
|
"test.blank",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2014-03-07 18:29:23 +00:00
|
|
|
[],
|
|
|
|
|
null,
|
|
|
|
|
"example"
|
|
|
|
|
]
|
2019-07-16 00:15:32 +00:00
|
|
|
]);'
|
2016-02-17 09:09:32 +00:00
|
|
|
] ],
|
|
|
|
|
[ [
|
2014-04-30 21:06:51 +00:00
|
|
|
'msg' => 'Conditional dependency function',
|
2016-02-17 09:09:32 +00:00
|
|
|
'modules' => [
|
2019-07-11 19:48:57 +00:00
|
|
|
'test.x.core' => [ 'class' => ResourceLoaderTestModule::class ],
|
|
|
|
|
'test.x.polyfill' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
2014-04-30 21:06:51 +00:00
|
|
|
'skipFunction' => 'return true;'
|
2019-07-11 19:48:57 +00:00
|
|
|
],
|
|
|
|
|
'test.y.polyfill' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
2014-04-30 21:06:51 +00:00
|
|
|
'skipFunction' =>
|
|
|
|
|
'return !!(' .
|
|
|
|
|
' window.JSON &&' .
|
|
|
|
|
' JSON.parse &&' .
|
|
|
|
|
' JSON.stringify' .
|
|
|
|
|
');'
|
2019-07-11 19:48:57 +00:00
|
|
|
],
|
|
|
|
|
'test.z.foo' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
2016-02-17 09:09:32 +00:00
|
|
|
'dependencies' => [
|
2014-04-30 21:06:51 +00:00
|
|
|
'test.x.core',
|
2014-10-25 00:18:24 +00:00
|
|
|
'test.x.polyfill',
|
|
|
|
|
'test.y.polyfill',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2019-07-11 19:48:57 +00:00
|
|
|
],
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2014-04-30 21:06:51 +00:00
|
|
|
'out' => '
|
2019-07-16 00:15:32 +00:00
|
|
|
mw.loader.addSource({
|
2014-08-25 08:02:48 +00:00
|
|
|
"local": "/w/load.php"
|
2019-07-16 00:15:32 +00:00
|
|
|
});
|
|
|
|
|
mw.loader.register([
|
2014-04-30 21:06:51 +00:00
|
|
|
[
|
|
|
|
|
"test.x.core",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
""
|
2014-04-30 21:06:51 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.x.polyfill",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2014-04-30 21:06:51 +00:00
|
|
|
[],
|
|
|
|
|
null,
|
2014-12-09 00:29:19 +00:00
|
|
|
null,
|
2014-04-30 21:06:51 +00:00
|
|
|
"return true;"
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.y.polyfill",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2014-04-30 21:06:51 +00:00
|
|
|
[],
|
|
|
|
|
null,
|
2014-12-09 00:29:19 +00:00
|
|
|
null,
|
2014-04-30 21:06:51 +00:00
|
|
|
"return !!( window.JSON \u0026\u0026 JSON.parse \u0026\u0026 JSON.stringify);"
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.z.foo",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2014-04-30 21:06:51 +00:00
|
|
|
[
|
2014-10-25 00:18:24 +00:00
|
|
|
0,
|
|
|
|
|
1,
|
|
|
|
|
2
|
2014-04-30 21:06:51 +00:00
|
|
|
]
|
|
|
|
|
]
|
2021-01-23 07:33:38 +00:00
|
|
|
]);',
|
|
|
|
|
] ],
|
|
|
|
|
[ [
|
|
|
|
|
'msg' => 'ES6-only module',
|
|
|
|
|
'modules' => [
|
|
|
|
|
'test.es6' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'es6' => true
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'out' => '
|
|
|
|
|
mw.loader.addSource({
|
|
|
|
|
"local": "/w/load.php"
|
|
|
|
|
});
|
|
|
|
|
mw.loader.register([
|
|
|
|
|
[
|
|
|
|
|
"test.es6",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"!"
|
2021-01-23 07:33:38 +00:00
|
|
|
]
|
2021-09-28 01:37:54 +00:00
|
|
|
]);',
|
|
|
|
|
] ],
|
|
|
|
|
[ [
|
|
|
|
|
'msg' => 'noscript group omitted (T291735)',
|
|
|
|
|
'modules' => [
|
|
|
|
|
'test.not-noscript' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
],
|
|
|
|
|
'test.noscript' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'group' => 'noscript',
|
|
|
|
|
],
|
|
|
|
|
'test.also-noscript' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'group' => 'noscript',
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'out' => '
|
|
|
|
|
mw.loader.addSource({
|
|
|
|
|
"local": "/w/load.php"
|
|
|
|
|
});
|
|
|
|
|
mw.loader.register([
|
|
|
|
|
[
|
|
|
|
|
"test.not-noscript",
|
|
|
|
|
""
|
|
|
|
|
]
|
2019-07-16 00:15:32 +00:00
|
|
|
]);',
|
2016-02-17 09:09:32 +00:00
|
|
|
] ],
|
|
|
|
|
[ [
|
2014-03-07 18:29:23 +00:00
|
|
|
// This may seem like an edge case, but a plain MediaWiki core install
|
|
|
|
|
// with a few extensions installed is likely far more complex than this
|
|
|
|
|
// even, not to mention an install like Wikipedia.
|
|
|
|
|
// TODO: Make this even more realistic.
|
|
|
|
|
'msg' => 'Advanced (everything combined)',
|
2016-02-17 09:09:32 +00:00
|
|
|
'sources' => [
|
|
|
|
|
'example' => [
|
2014-03-07 18:29:23 +00:00
|
|
|
'loadScript' => 'http://example.org/w/load.php',
|
|
|
|
|
'apiScript' => 'http://example.org/w/api.php',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'modules' => [
|
2019-07-11 19:48:57 +00:00
|
|
|
'test.blank' => [ 'class' => ResourceLoaderTestModule::class ],
|
|
|
|
|
'test.x.core' => [ 'class' => ResourceLoaderTestModule::class ],
|
|
|
|
|
'test.x.util' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
2016-02-17 09:09:32 +00:00
|
|
|
'dependencies' => [
|
2014-03-07 18:29:23 +00:00
|
|
|
'test.x.core',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2019-07-11 19:48:57 +00:00
|
|
|
],
|
|
|
|
|
'test.x.foo' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
2016-02-17 09:09:32 +00:00
|
|
|
'dependencies' => [
|
2014-03-07 18:29:23 +00:00
|
|
|
'test.x.core',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2019-07-11 19:48:57 +00:00
|
|
|
],
|
|
|
|
|
'test.x.bar' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
2016-02-17 09:09:32 +00:00
|
|
|
'dependencies' => [
|
2014-03-07 18:29:23 +00:00
|
|
|
'test.x.core',
|
|
|
|
|
'test.x.util',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2019-07-11 19:48:57 +00:00
|
|
|
],
|
|
|
|
|
'test.x.quux' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
2016-02-17 09:09:32 +00:00
|
|
|
'dependencies' => [
|
2014-03-07 18:29:23 +00:00
|
|
|
'test.x.foo',
|
|
|
|
|
'test.x.bar',
|
|
|
|
|
'test.x.util',
|
2013-07-07 22:51:15 +00:00
|
|
|
'test.x.unknown',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2019-07-11 19:48:57 +00:00
|
|
|
],
|
|
|
|
|
'test.group.foo.1' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
2014-03-07 18:29:23 +00:00
|
|
|
'group' => 'x-foo',
|
2019-07-11 19:48:57 +00:00
|
|
|
],
|
|
|
|
|
'test.group.foo.2' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
2014-03-07 18:29:23 +00:00
|
|
|
'group' => 'x-foo',
|
2019-07-11 19:48:57 +00:00
|
|
|
],
|
|
|
|
|
'test.group.bar.1' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
2014-03-07 18:29:23 +00:00
|
|
|
'group' => 'x-bar',
|
2019-07-11 19:48:57 +00:00
|
|
|
],
|
|
|
|
|
'test.group.bar.2' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
2014-03-07 18:29:23 +00:00
|
|
|
'group' => 'x-bar',
|
|
|
|
|
'source' => 'example',
|
2019-07-11 19:48:57 +00:00
|
|
|
],
|
|
|
|
|
'test.target.foo' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
2016-02-17 09:09:32 +00:00
|
|
|
'targets' => [ 'x-foo' ],
|
2019-07-11 19:48:57 +00:00
|
|
|
],
|
|
|
|
|
'test.target.bar' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
2014-03-07 18:29:23 +00:00
|
|
|
'source' => 'example',
|
2016-02-17 09:09:32 +00:00
|
|
|
'targets' => [ 'x-foo' ],
|
2019-07-11 19:48:57 +00:00
|
|
|
],
|
2021-01-23 07:33:38 +00:00
|
|
|
'test.es6' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'es6' => true
|
|
|
|
|
]
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2014-03-07 18:29:23 +00:00
|
|
|
'out' => '
|
2019-07-16 00:15:32 +00:00
|
|
|
mw.loader.addSource({
|
2014-08-25 08:02:48 +00:00
|
|
|
"local": "/w/load.php",
|
|
|
|
|
"example": "http://example.org/w/load.php"
|
2019-07-16 00:15:32 +00:00
|
|
|
});
|
|
|
|
|
mw.loader.register([
|
2014-03-07 18:29:23 +00:00
|
|
|
[
|
|
|
|
|
"test.blank",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
""
|
2014-03-07 18:29:23 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.x.core",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
""
|
2014-03-07 18:29:23 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.x.util",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2014-03-07 18:29:23 +00:00
|
|
|
[
|
2014-10-25 00:18:24 +00:00
|
|
|
1
|
2014-03-07 18:29:23 +00:00
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.x.foo",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2014-03-07 18:29:23 +00:00
|
|
|
[
|
2014-10-25 00:18:24 +00:00
|
|
|
1
|
2014-03-07 18:29:23 +00:00
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.x.bar",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2014-03-07 18:29:23 +00:00
|
|
|
[
|
2014-10-25 00:18:24 +00:00
|
|
|
2
|
2014-03-07 18:29:23 +00:00
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.x.quux",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2014-03-07 18:29:23 +00:00
|
|
|
[
|
2014-10-25 00:18:24 +00:00
|
|
|
3,
|
|
|
|
|
4,
|
2013-07-07 22:51:15 +00:00
|
|
|
"test.x.unknown"
|
2014-03-07 18:29:23 +00:00
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.group.foo.1",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2014-03-07 18:29:23 +00:00
|
|
|
[],
|
2019-08-14 19:39:01 +00:00
|
|
|
2
|
2014-03-07 18:29:23 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.group.foo.2",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2014-03-07 18:29:23 +00:00
|
|
|
[],
|
2019-08-14 19:39:01 +00:00
|
|
|
2
|
2014-03-07 18:29:23 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.group.bar.1",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2014-03-07 18:29:23 +00:00
|
|
|
[],
|
2019-08-14 19:39:01 +00:00
|
|
|
3
|
2014-03-07 18:29:23 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.group.bar.2",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2014-03-07 18:29:23 +00:00
|
|
|
[],
|
2019-08-14 19:39:01 +00:00
|
|
|
3,
|
2014-03-07 18:29:23 +00:00
|
|
|
"example"
|
2021-01-23 07:33:38 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.es6",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"!"
|
2014-03-07 18:29:23 +00:00
|
|
|
]
|
2019-07-16 00:15:32 +00:00
|
|
|
]);'
|
2016-02-17 09:09:32 +00:00
|
|
|
] ],
|
|
|
|
|
];
|
2014-03-07 18:29:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider provideGetModuleRegistrations
|
2022-05-06 09:09:56 +00:00
|
|
|
* @covers \MediaWiki\ResourceLoader\StartUpModule
|
|
|
|
|
* @covers \MediaWiki\ResourceLoader\ResourceLoader::makeLoaderRegisterScript
|
2014-03-07 18:29:23 +00:00
|
|
|
*/
|
|
|
|
|
public function testGetModuleRegistrations( $case ) {
|
2017-10-06 22:17:58 +00:00
|
|
|
$extraQuery = $case['extraQuery'] ?? [];
|
2018-03-28 00:57:06 +00:00
|
|
|
$context = $this->getResourceLoaderContext( $extraQuery );
|
2014-03-07 18:29:23 +00:00
|
|
|
$rl = $context->getResourceLoader();
|
2019-03-29 01:21:18 +00:00
|
|
|
if ( isset( $case['sources'] ) ) {
|
|
|
|
|
$rl->addSource( $case['sources'] );
|
|
|
|
|
}
|
2014-03-07 18:29:23 +00:00
|
|
|
$rl->register( $case['modules'] );
|
2022-05-06 09:09:56 +00:00
|
|
|
$module = new StartUpModule();
|
2021-06-11 15:11:37 +00:00
|
|
|
$module->setConfig( $rl->getConfig() );
|
2015-11-17 04:22:15 +00:00
|
|
|
$out = ltrim( $case['out'], "\n" );
|
|
|
|
|
|
2017-07-13 05:16:53 +00:00
|
|
|
// Disable log from getModuleRegistrations via MWExceptionHandler
|
|
|
|
|
// for case where getVersionHash() is expected to throw.
|
2022-05-06 09:09:56 +00:00
|
|
|
$this->setLogger( 'exception', new \Psr\Log\NullLogger() );
|
2017-07-13 05:16:53 +00:00
|
|
|
|
2014-03-07 18:29:23 +00:00
|
|
|
$this->assertEquals(
|
2015-11-17 04:22:15 +00:00
|
|
|
self::expandPlaceholders( $out ),
|
2014-08-07 10:25:56 +00:00
|
|
|
$module->getModuleRegistrations( $context ),
|
2014-03-07 18:29:23 +00:00
|
|
|
$case['msg']
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
/**
|
|
|
|
|
* These test cases test behaviour that are specific to production mode.
|
|
|
|
|
*
|
|
|
|
|
* @see provideGetModuleRegistrations
|
|
|
|
|
*/
|
|
|
|
|
public function provideGetModuleRegistrationsProduction() {
|
|
|
|
|
yield 'Version falls back gracefully if getModuleContent throws' => [ [
|
|
|
|
|
'modules' => [
|
|
|
|
|
'test.fail' => [
|
|
|
|
|
'factory' => function () {
|
|
|
|
|
$mock = $this->getMockBuilder( ResourceLoaderTestModule::class )
|
|
|
|
|
->onlyMethods( [ 'getModuleContent' ] )->getMock();
|
|
|
|
|
$mock->method( 'getModuleContent' )->will(
|
|
|
|
|
$this->throwException( new Exception )
|
|
|
|
|
);
|
|
|
|
|
return $mock;
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'out' => 'mw.loader.addSource({"local":"/w/load.php"});' . "\n"
|
|
|
|
|
. 'mw.loader.register([["test.fail",""]]);' . "\n"
|
|
|
|
|
. 'mw.loader.state({"test.fail":"error"});',
|
|
|
|
|
] ];
|
|
|
|
|
yield 'Version falls back gracefully if getDefinitionSummary throws' => [ [
|
|
|
|
|
'modules' => [
|
|
|
|
|
'test.fail' => [
|
|
|
|
|
'factory' => function () {
|
|
|
|
|
$mock = $this->getMockBuilder( ResourceLoaderTestModule::class )
|
|
|
|
|
->onlyMethods( [
|
|
|
|
|
'enableModuleContentVersion',
|
|
|
|
|
'getDefinitionSummary'
|
|
|
|
|
] )
|
|
|
|
|
->getMock();
|
|
|
|
|
$mock->method( 'enableModuleContentVersion' )->willReturn( false );
|
|
|
|
|
$mock->method( 'getDefinitionSummary' )->will(
|
|
|
|
|
$this->throwException( new Exception )
|
|
|
|
|
);
|
|
|
|
|
return $mock;
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'out' => 'mw.loader.addSource({"local":"/w/load.php"});' . "\n"
|
|
|
|
|
. 'mw.loader.register([["test.fail",""]]);' . "\n"
|
|
|
|
|
. 'mw.loader.state({"test.fail":"error"});',
|
|
|
|
|
] ];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider provideGetModuleRegistrationsProduction
|
2022-05-06 09:09:56 +00:00
|
|
|
* @covers \MediaWiki\ResourceLoader\StartUpModule
|
|
|
|
|
* @covers \MediaWiki\ResourceLoader\ResourceLoader
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
*/
|
|
|
|
|
public function testGetModuleRegistrationsProduction( array $case ) {
|
|
|
|
|
$context = $this->getResourceLoaderContext( [ 'debug' => 'false' ] );
|
|
|
|
|
$rl = $context->getResourceLoader();
|
|
|
|
|
$rl->register( $case['modules'] );
|
|
|
|
|
$module = new ResourceLoaderStartUpModule();
|
|
|
|
|
$module->setConfig( $rl->getConfig() );
|
|
|
|
|
$out = ltrim( $case['out'], "\n" );
|
|
|
|
|
|
|
|
|
|
// Tolerate exception logs for cases that expect getVersionHash() to throw.
|
2022-05-06 09:09:56 +00:00
|
|
|
$this->setLogger( 'exception', new \Psr\Log\NullLogger() );
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
self::expandPlaceholders( $out ),
|
|
|
|
|
$module->getModuleRegistrations( $context )
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-30 21:06:51 +00:00
|
|
|
public static function provideRegistrations() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
|
|
|
|
[ [
|
2019-07-11 19:48:57 +00:00
|
|
|
'test.blank' => [ 'class' => ResourceLoaderTestModule::class ],
|
|
|
|
|
'test.min' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
2014-04-30 21:06:51 +00:00
|
|
|
'skipFunction' =>
|
|
|
|
|
'return !!(' .
|
|
|
|
|
' window.JSON &&' .
|
|
|
|
|
' JSON.parse &&' .
|
|
|
|
|
' JSON.stringify' .
|
|
|
|
|
');',
|
2016-02-17 09:09:32 +00:00
|
|
|
'dependencies' => [
|
2014-04-30 21:06:51 +00:00
|
|
|
'test.blank',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2019-07-11 19:48:57 +00:00
|
|
|
],
|
2016-02-17 09:09:32 +00:00
|
|
|
] ]
|
|
|
|
|
];
|
2014-04-30 21:06:51 +00:00
|
|
|
}
|
2019-01-15 15:04:58 +00:00
|
|
|
|
2014-04-30 21:06:51 +00:00
|
|
|
/**
|
2022-05-06 09:09:56 +00:00
|
|
|
* @covers \MediaWiki\ResourceLoader\StartUpModule::getModuleRegistrations
|
2014-04-30 21:06:51 +00:00
|
|
|
* @dataProvider provideRegistrations
|
|
|
|
|
*/
|
|
|
|
|
public function testRegistrationsMinified( $modules ) {
|
2019-09-09 15:50:13 +00:00
|
|
|
$context = $this->getResourceLoaderContext( [
|
|
|
|
|
'debug' => 'false',
|
|
|
|
|
] );
|
2014-04-30 21:06:51 +00:00
|
|
|
$rl = $context->getResourceLoader();
|
|
|
|
|
$rl->register( $modules );
|
2014-08-07 10:25:56 +00:00
|
|
|
$module = new ResourceLoaderStartUpModule();
|
2021-06-11 15:11:37 +00:00
|
|
|
$module->setConfig( $rl->getConfig() );
|
2015-11-17 04:22:15 +00:00
|
|
|
$out = 'mw.loader.addSource({"local":"/w/load.php"});' . "\n"
|
|
|
|
|
. 'mw.loader.register(['
|
|
|
|
|
. '["test.blank","{blankVer}"],'
|
|
|
|
|
. '["test.min","{blankVer}",[0],null,null,'
|
|
|
|
|
. '"return!!(window.JSON\u0026\u0026JSON.parse\u0026\u0026JSON.stringify);"'
|
|
|
|
|
. ']]);';
|
|
|
|
|
|
2014-04-30 21:06:51 +00:00
|
|
|
$this->assertEquals(
|
2015-11-17 04:22:15 +00:00
|
|
|
self::expandPlaceholders( $out ),
|
2014-08-07 10:25:56 +00:00
|
|
|
$module->getModuleRegistrations( $context ),
|
2014-04-30 21:06:51 +00:00
|
|
|
'Minified output'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-05-06 09:09:56 +00:00
|
|
|
* @covers \MediaWiki\ResourceLoader\StartUpModule::getModuleRegistrations
|
2014-04-30 21:06:51 +00:00
|
|
|
* @dataProvider provideRegistrations
|
|
|
|
|
*/
|
|
|
|
|
public function testRegistrationsUnminified( $modules ) {
|
2019-09-09 15:50:13 +00:00
|
|
|
$context = $this->getResourceLoaderContext( [
|
|
|
|
|
'debug' => 'true',
|
|
|
|
|
] );
|
2014-04-30 21:06:51 +00:00
|
|
|
$rl = $context->getResourceLoader();
|
|
|
|
|
$rl->register( $modules );
|
2014-08-07 10:25:56 +00:00
|
|
|
$module = new ResourceLoaderStartUpModule();
|
2021-06-11 15:11:37 +00:00
|
|
|
$module->setConfig( $rl->getConfig() );
|
2015-11-17 04:22:15 +00:00
|
|
|
$out =
|
2019-07-16 00:15:32 +00:00
|
|
|
'mw.loader.addSource({
|
2014-08-25 08:02:48 +00:00
|
|
|
"local": "/w/load.php"
|
2019-07-16 00:15:32 +00:00
|
|
|
});
|
|
|
|
|
mw.loader.register([
|
2014-04-30 21:06:51 +00:00
|
|
|
[
|
|
|
|
|
"test.blank",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
""
|
2014-04-30 21:06:51 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
"test.min",
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
"",
|
2014-04-30 21:06:51 +00:00
|
|
|
[
|
2014-10-25 00:18:24 +00:00
|
|
|
0
|
2014-04-30 21:06:51 +00:00
|
|
|
],
|
|
|
|
|
null,
|
2014-12-09 00:29:19 +00:00
|
|
|
null,
|
2014-04-30 21:06:51 +00:00
|
|
|
"return !!( window.JSON \u0026\u0026 JSON.parse \u0026\u0026 JSON.stringify);"
|
|
|
|
|
]
|
2019-07-16 00:15:32 +00:00
|
|
|
]);';
|
2015-11-17 04:22:15 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
self::expandPlaceholders( $out ),
|
2014-08-07 10:25:56 +00:00
|
|
|
$module->getModuleRegistrations( $context ),
|
2014-04-30 21:06:51 +00:00
|
|
|
'Unminified output'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-24 01:59:44 +00:00
|
|
|
/**
|
2022-05-06 09:09:56 +00:00
|
|
|
* @covers \MediaWiki\ResourceLoader\StartUpModule
|
2018-06-24 01:59:44 +00:00
|
|
|
*/
|
|
|
|
|
public function testGetVersionHash_varyConfig() {
|
|
|
|
|
$context = $this->getResourceLoaderContext();
|
|
|
|
|
|
2020-05-26 13:14:46 +00:00
|
|
|
$module = new ResourceLoaderStartUpModule();
|
2021-06-11 15:11:37 +00:00
|
|
|
$module->setConfig( $context->getResourceLoader()->getConfig() );
|
2018-06-24 01:59:44 +00:00
|
|
|
$version1 = $module->getVersionHash( $context );
|
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-30 02:52:39 +00:00
|
|
|
|
2020-05-26 13:14:46 +00:00
|
|
|
$module = new ResourceLoaderStartUpModule();
|
2021-06-11 15:11:37 +00:00
|
|
|
$module->setConfig( $context->getResourceLoader()->getConfig() );
|
|
|
|
|
$version2 = $module->getVersionHash( $context );
|
2018-06-24 01:59:44 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
$version1,
|
|
|
|
|
$version2,
|
|
|
|
|
'Deterministic version hash'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-08 06:48:35 +00:00
|
|
|
/**
|
2022-05-06 09:09:56 +00:00
|
|
|
* @covers \MediaWiki\ResourceLoader\StartUpModule
|
2018-07-08 06:48:35 +00:00
|
|
|
*/
|
|
|
|
|
public function testGetVersionHash_varyModule() {
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
$context1 = $this->getResourceLoaderContext( [
|
|
|
|
|
'debug' => 'false',
|
|
|
|
|
] );
|
2018-07-08 06:48:35 +00:00
|
|
|
$rl1 = $context1->getResourceLoader();
|
|
|
|
|
$rl1->register( [
|
2019-07-11 19:48:57 +00:00
|
|
|
'test.a' => [ 'class' => ResourceLoaderTestModule::class ],
|
|
|
|
|
'test.b' => [ 'class' => ResourceLoaderTestModule::class ],
|
2018-07-08 06:48:35 +00:00
|
|
|
] );
|
2020-05-26 13:14:46 +00:00
|
|
|
$module = new ResourceLoaderStartUpModule();
|
2021-06-11 15:11:37 +00:00
|
|
|
$module->setConfig( $rl1->getConfig() );
|
2018-07-08 06:48:35 +00:00
|
|
|
$version1 = $module->getVersionHash( $context1 );
|
|
|
|
|
|
|
|
|
|
$context2 = $this->getResourceLoaderContext();
|
|
|
|
|
$rl2 = $context2->getResourceLoader();
|
|
|
|
|
$rl2->register( [
|
2019-07-11 19:48:57 +00:00
|
|
|
'test.b' => [ 'class' => ResourceLoaderTestModule::class ],
|
|
|
|
|
'test.c' => [ 'class' => ResourceLoaderTestModule::class ],
|
2018-07-08 06:48:35 +00:00
|
|
|
] );
|
2020-05-26 13:14:46 +00:00
|
|
|
$module = new ResourceLoaderStartUpModule();
|
2021-06-11 15:11:37 +00:00
|
|
|
$module->setConfig( $rl2->getConfig() );
|
2018-07-08 06:48:35 +00:00
|
|
|
$version2 = $module->getVersionHash( $context2 );
|
|
|
|
|
|
|
|
|
|
$context3 = $this->getResourceLoaderContext();
|
|
|
|
|
$rl3 = $context3->getResourceLoader();
|
|
|
|
|
$rl3->register( [
|
2019-07-11 19:48:57 +00:00
|
|
|
'test.a' => [ 'class' => ResourceLoaderTestModule::class ],
|
|
|
|
|
'test.b' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'script' => 'different',
|
|
|
|
|
],
|
2018-07-08 06:48:35 +00:00
|
|
|
] );
|
2020-05-26 13:14:46 +00:00
|
|
|
$module = new ResourceLoaderStartUpModule();
|
2021-06-11 15:11:37 +00:00
|
|
|
$module->setConfig( $rl3->getConfig() );
|
2018-07-08 06:48:35 +00:00
|
|
|
$version3 = $module->getVersionHash( $context3 );
|
|
|
|
|
|
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-30 02:52:39 +00:00
|
|
|
// Module name *is* significant (T201686)
|
|
|
|
|
$this->assertNotEquals(
|
2018-07-08 06:48:35 +00:00
|
|
|
$version1,
|
|
|
|
|
$version2,
|
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-30 02:52:39 +00:00
|
|
|
'Module name is significant'
|
2018-07-08 06:48:35 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->assertNotEquals(
|
|
|
|
|
$version1,
|
|
|
|
|
$version3,
|
|
|
|
|
'Hash change of any module impacts startup hash'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
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-30 02:52:39 +00:00
|
|
|
/**
|
2022-05-06 09:09:56 +00:00
|
|
|
* @covers \MediaWiki\ResourceLoader\StartUpModule
|
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-30 02:52:39 +00:00
|
|
|
*/
|
|
|
|
|
public function testGetVersionHash_varyDeps() {
|
resourceloader: Skip version hash calculation in debug mode
=== Why
* More speed
In debug mode, the server should regenerate the startup manifest
on each page view to ensure immediate effect of changes. But,
this also means more version recomputation work on the server.
For most modules, this was already quite fast on repeat views
because of OS-level file caches, and our file-hash caches and
LESS compile caches in php-apcu from ResourceLoader.
But, this makes it even faster.
* Better integration with browser devtools.
Breakpoints stay more consistently across browsers when the
URL stays the same even after you have changed the file and
reloaded the page. For static files, I believe most browsers ignore
query parameters. But for package files that come from load.php,
this was harder for browsers to guess correctly which old script URL
is logically replaced by a different one on the next page view.
=== How
Change Module::getVersionHash to return empty strings in debug mode.
I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.
I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.
Also, those calls would still be incurring some the avoidable costs.
=== Notes
* The two test cases for verifying the graceful fallback in production
if version hash computations throw an exception, were moved to a
non-debug test case as no longer happen now during the debug
(unminified) test cases.
* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
by adding a fallback to empty string so that if the test fails,
it fails in a more useful way instead of aborting with this error
before the assertion happens. (Since PHPUnit generally stops on the
first error.)
* In practice, there are still "version" query parameters and E-Tag
headers in debug mode. These are not module versions, but URL
"combined versions" crafted by getCombinedVersion() in JS and PHP.
These return the constant "ztntf" in debug mode, which is the hash
of an empty string. We could alter these methods to special-case
when all inputs are and join to a still-empty string, or maybe we
just leave them be. I've done the latter for now.
Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-08-28 02:53:36 +00:00
|
|
|
$context = $this->getResourceLoaderContext( [ 'debug' => 'false' ] );
|
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-30 02:52:39 +00:00
|
|
|
$rl = $context->getResourceLoader();
|
|
|
|
|
$rl->register( [
|
2019-07-11 19:48:57 +00:00
|
|
|
'test.a' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'dependencies' => [ 'x', 'y' ],
|
|
|
|
|
],
|
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-30 02:52:39 +00:00
|
|
|
] );
|
2020-05-26 13:14:46 +00:00
|
|
|
$module = new ResourceLoaderStartUpModule();
|
2021-06-11 15:11:37 +00:00
|
|
|
$module->setConfig( $rl->getConfig() );
|
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-30 02:52:39 +00:00
|
|
|
$version1 = $module->getVersionHash( $context );
|
|
|
|
|
|
|
|
|
|
$context = $this->getResourceLoaderContext();
|
|
|
|
|
$rl = $context->getResourceLoader();
|
|
|
|
|
$rl->register( [
|
2019-07-11 19:48:57 +00:00
|
|
|
'test.a' => [
|
|
|
|
|
'class' => ResourceLoaderTestModule::class,
|
|
|
|
|
'dependencies' => [ 'x', 'z' ],
|
|
|
|
|
],
|
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-30 02:52:39 +00:00
|
|
|
] );
|
2020-05-26 13:14:46 +00:00
|
|
|
$module = new ResourceLoaderStartUpModule();
|
2021-06-11 15:11:37 +00:00
|
|
|
$module->setConfig( $rl->getConfig() );
|
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-30 02:52:39 +00:00
|
|
|
$version2 = $module->getVersionHash( $context );
|
|
|
|
|
|
|
|
|
|
// Dependencies *are* significant (T201686)
|
|
|
|
|
$this->assertNotEquals(
|
|
|
|
|
$version1,
|
|
|
|
|
$version2,
|
|
|
|
|
'Dependencies are significant'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-07 18:29:23 +00:00
|
|
|
}
|