Commit graph

1720 commits

Author SHA1 Message Date
Umherirrender
47cc4da6d7 Remove unneeded @return documentation
Change-Id: If79d2126cc1b6a6e9876a972c9560d045de42ff6
2021-01-25 19:44:27 +01:00
Ppchelko
bdb5f394d3 Revert "Enhance GroupPermissionsLookup and use it."
This reverts commit 900c6663b0.

Reason for revert: breaks Parsoid CI. Instead of fixing the test in presence of the FlaggedRevs hook, I would rather convert DefaultPreferencesFactory to Authority and fix the tests once instead of doing it twice.

Change-Id: Iaa440a9804c9ed97339e737162ef64ccf29ceb51
2021-01-12 04:48:49 +00:00
Petr Pchelko
900c6663b0 Enhance GroupPermissionsLookup and use it.
Added new methods:
- ::getGroupsWithAnyPermissions
- ::getGroupsWithAllPermissions
- ::groupHasAnyPermission
- ::groupHasAllPermission

Replaced relevant calls to PermissionManager with
calls to GroupPermissionsLookup.

Bug: T254537
Change-Id: I0b9c3352c5bebc94e1649239fe0527144e7c2eb2
2021-01-11 11:05:54 -06:00
James D. Forrester
abdc94a3da Swap out uses of User->isLoggedIn() with ->isRegistered()
Bug: T270450
Change-Id: I90ff94a553ebae9a4ef97c25c333f067f19c327d
2020-12-22 03:13:37 +00:00
DannyS712
f4e21014ce Deprecate a bunch of global functions
* wfAcceptToPrefs
* wfClearOutputBuffers
* wfConfiguredReadOnlyReason
* wfDebugMem
* wfGetPrecompiledData
* wfNegotiateType

Bug: T264976
Bug: T264979
Bug: T264981
Bug: T264983
Bug: T264984
Bug: T264985
Change-Id: Ia05bc84e4d1be7c8a02472f32e2c009e4bb32032
2020-12-18 21:34:50 +00:00
DannyS712
b5e7f210cd SECURITY: Act like users don't exist if hidden from viewer
When viewing Special:Contributions for a hidden user and
a missing user, or the user page of a hidden user and a
missing user, if the viewer cannot see hidden users
the output should be the same for hidden users and
missing users.

To that end
* In OutputPage.php, only set the `wgRelevantUserName` javascript
  variable if the user is not hidden, or the viewer can see hidden
  users
* In Article.php, show the `userpage-userdoesnotexist-view` on user
  pages of hidden users if the viewer cannot see hidden users
* In Skin.php, do not add user-specific sidebar links (contributions,
  logs, mute, etc.) if the user is hidden and the viewer cannot see
  hidden users
* In SpecialContributions.php, stop calling Skin::setRelevantUser
  for non-existing users, so that callers of Skin::getRelevantUser
  can ignore users that are hidden from the viewer without creating
  divergent behavior
* In SpecialContributions.php, for users that do exist but are
  hidden from the viewer, don't show `sp-contributions-footer`,
  but do show `contributions-userdoesnotexist`

Bug: T120883
Change-Id: I83b723402f315447bc4b50992e28620e3daace8f
2020-12-18 00:35:54 +00:00
C. Scott Ananian
c64e71615e Replace $wgDisable{Lang,Title}Conversion with LanguageConverterFactory methods
Replace direct access to $wgDisableLangConversion with
LanguageConverterFactory::isConversionDisabled(), and replace direct
access to $wgDisableTitleConversion with
LanguageConverterFactory::isTitleConversionDisabled().  However, most
places that check ::isTitleConversionDisabled() actually want
::isLinkConversionDisabled(), so add that too (and deprecate
isTitleConversionDisabled()).

Code search:
https://codesearch.wmcloud.org/search/?q=Disable%28Lang|Title%29Conversion&i=nope&files=&repos=

This change removes a number of spurious dependencies on the global
configuration and reduces code duplication (for example, if the logic
for disabling language conversion were ever to change).

Depends-On: I6fa8230ae97b0e34c381003548e61f9b7387d363
Change-Id: Icc4687638ff1815003dd903854efdbd904854f1e
2020-11-25 12:47:26 -05:00
jdlrobson
d11cb401d6 Deprecate the use of Skin::setupSkinUserCss to alter the internal array of styles
Check the internal array of styles to determine whether
the method was inappropriately used to alter the array of styles and
if it was, call wfDeprecatedMsg().

Change-Id: I591b03c2e19d4b8cadfe220b498ae244d332f9fb
2020-11-24 10:49:09 +11:00
Tim Starling
e9608cc17d Revert "Deprecate Skin::setupSkinUserCss"
The commit did not really hard-deprecate overriding of setupSkinUserCss() as stated in the commit message, rather it removed core calls to setupSkinUserCss(), instantly breaking the many skins that still override it. It did not actually create a deprecation period for graceful migration.

As discussed in T267080, there is presently no way to hard-deprecate the override of a method.

This reverts commit 334cfeffd6.

Bug: T257990
Change-Id: I8f669ba30affc437800890c3a875994a9f2eb3c8
2020-11-24 10:03:11 +11:00
jenkins-bot
1976283835 Merge "Update a lot of unspecific "array" types in PHPDocs" 2020-11-13 21:48:24 +00:00
jenkins-bot
32fed9c635 Merge "resourceloader: Remove wfExpandUrl() coupling from CSSMin" 2020-11-13 07:07:49 +00:00
jenkins-bot
b8f3822d52 Merge "Reduce some references to $wgUser" 2020-11-09 14:53:37 +00:00
Brad Jorsch
cd54c03e86 resourceloader: Remove wfExpandUrl() coupling from CSSMin
There are three cases in CSSMin::remap where performs path
resolution.

1. Absolute local path URLs to full URL.
   Example: url(/static/foo.png), url(/w/index.php?…), etc.

   These previously used wfExpandUrl(), which got the server
   name and protocol directly from $wgServer.

   We will now use the $remote parameter to get this information
   instead, which is generally set to something like
   https://wiki/w/resources/foo, and thus naturally contains
   the server name and protocol.

   The resolution is powered by the Net_URL2 library, allowing
   this to work outside Mediawiki as well.

   Some tests needed to change because they were calling CSSMin::remap
   with an incomplete $remote dummy values like "/" or "/w, because
   the test author (past me) was trying to be clever by not supplying
   it, knowing MW would ignore it. Now that it is consistently used,
   like normal calls from ResourceLoader would, the expected values
   will always be based on http://localhost/w, instead of sometimes
   the competing $wgServer value of `https://expand.example`.

2. Relative local path to full URL
   Example: url(foo.png), url(../foo.png), url(bar/foo.png)

   These were already using $remote. The only change is that
   they now use Net_URL2 library instead of blind string
   concatenation. One of the benefits of this is that we will
   no longer need to call wfRemoveDotSegments() to get rid
   of things like double slashes or redundant "../" sequences.
   Previously, thing like "foo//bar" or "foo/../bar" were cleaned
   up only due to wfRemoveDotSegments(). This is now naturally
   handled by Net_URL2.

3. Remote URLs
   Example: url(http://example.org/bar.png), url(//example.org/bar.png)

   This is generally not used in source code, but gadgets may use this,
   e.g. for upload.wikimedia.org or cross-wiki imports.

Other changes:

* One test case used spaces within the URL string in CSS, which the
  net_url2 library represents with percent-encoding instead.
  Same thing either way.

Bug: T88914
Change-Id: Ibef70cc934c0ee8260a244c51bca9fb88c1c0d88
2020-11-05 19:59:02 +00:00
Tim Starling
5ada7df93e Log the reason for private caching
In OutputPage::sendCacheControl(), break up the multi-line conditional
and include in the debug log message the reason for private cache
headers being sent. I think this improves the readability of the code.

Change-Id: I0229e04c44771245b7ac8cd45d2c83062a4d78f2
2020-11-05 13:12:42 +11:00
jenkins-bot
929381a81f Merge "Use LinkBatchFactory" 2020-11-01 20:48:02 +00:00
Umherirrender
c85a43561e Improve class property documentation
Reformat existing documentation to match the format

Change-Id: I190b54b5e962f17bab6502dd1b3c02f11dc926d2
2020-10-30 10:38:58 +01:00
Thiemo Kreuz
b0130ca649 Update a lot of unspecific "array" types in PHPDocs
This includes fixing some mistakes, as well as removing
redundant text that doesn't add new information, either because
it literally repeats what the code already says, or is actually
duplicated.

Change-Id: I3a8dd8ce57192deda8916cc444c87d7ab1a36515
2020-10-28 11:01:33 +01:00
Thiemo Kreuz
1fc8d79ac6 Remove documentation that literally repeats the code
For example, documenting the method getUser() with "get the User
object" does not add any information that's not already there.
But I have to read the text first to understand that it doesn't
document anything that's not already obvious from the code.

Some of this is from a time when we had a PHPCS sniff that was
complaining when a line like `@param User $user` doesn't end
with some descriptive text. Some users started adding text like
`@param User $user The User` back then. Let's please remove
this.

Change-Id: I0ea8d051bc732466c73940de9259f87ffb86ce7a
2020-10-27 19:20:26 +00:00
Umherirrender
973c562927 Use LinkBatchFactory
Change-Id: Ib82f91048faad8cf8be961d038f30c9261072af5
2020-10-25 23:21:42 +01:00
ArtBaltai
e7dbd69de0 Hard deprecation of Language::convertTitle(),
::findVariantLink(), ::updateConversionTable()

Co-authored-by: C. Scott Ananian <cananian@wikimedia.org>
Bug: T226832
Change-Id: I41a3b67490fc6b9d4c484f566d346a0d10c670e9
2020-10-20 16:49:17 -04:00
DannyS712
cf5fd868cd Reduce some references to $wgUser
Should be a no-op

Bug: T243708
Change-Id: I7b204cdc629c6c33e6a84b5c7a4e0e7ac321f19d
2020-10-13 15:07:27 +00:00
Umherirrender
7c539e9c72 Avoid null query in Skin::lastModified
For action=history there is a query:
SELECT rev_timestamp FROM `revision` WHERE rev_id IS NULL LIMIT 1
to generate the footer links

Change-Id: I8b0f30f874eb73544693dff9d12d45585bd9a110
2020-08-18 13:41:53 +02:00
Timo Tijhof
274c4232b9 mediawiki.page.startup: Merge with mediawiki.page.ready module
The distinction between the two was lost several years years ago
when the "position top" queue ceased to be a thing. Since then,
the two have been loaded and executed together in the same batch,
and are doing similar things.

mediawiki.page.ready is publicly used in several places
as dependendency, but mediawiki.page.startup is entirely internal
to core, which makes it the easier one of the two to dissolve.

Keep an alias for two weeks for cache compat to avoid console
warnings about unknown modules. Although even some cache still
refers to it, this is harmless since the errors are recoverable
and the correct module was also loaded by the cached pages
already.

Bug: T260210
Change-Id: Ic418c23a7400abba22fd07b17f173d3c5f1d1d10
2020-08-14 01:35:15 +00:00
Ammar Abdulhamid
334cfeffd6 Deprecate Skin::setupSkinUserCss
Bug: T257990
Depends-On: I132513a897e40162acd973b9817b3103f4a33333
Depends-On: I363f8c9e39298ab9f74274d288681f2ef88a1894
Change-Id: I13bedd8c14de419ff1a88d5087f5669652cd3123
2020-08-09 02:09:08 +01:00
mainframe98
204ddf0522 Skin: Add a skin option for responsiveness
Skins can now specify responsive in the skin option, which will add
a meta tag with the value width=device-width, initial-scale=1.0,
user-scalable=yes, minimum-scale=0.25, maximum-scale=5.0.
If responsiveness is not constant, but based on, for example, a
user preference, then skins can override isResponsive to indicate
when the skin is responsive.

When enabled, it will also add the skin--responsive class to <body>.

Bug: T258290
Change-Id: I6e69b482cdbc49c09adc6f7cee54f5e17b7c92c4
2020-08-04 10:31:09 +00:00
Ed Sanders
7683f7d839 Use strict (in)equality with namespaces constants when LHS is definitely an integer
Change-Id: I8fede00dfe1270d93c5d78d3c36e788cddfc8a99
2020-07-31 18:03:28 +01:00
Amir Sarabadani
5fb5dab231 Drop html5shiv
According to T248061 the basic support for IE8 is gone now meaning we
don't need to serve the snippet for html5shiv anymore.

Also dropping the html5shiv code.

Bug: T248061
Change-Id: I1a8dbd72ae68f518f52a76a80a3b54239720d20c
2020-07-21 11:11:08 +00:00
Timo Tijhof
1e82b201c1 OutputPage: Use @unstable instead of @internal for addHtmlClasses()
Follows-up 9d3254d18e.

Methods using @internal are designed for use internal to the component
that defines the method, and are generally considered safe to remove
anytime if they are unused.

This method however is not for internal use, it is designed for public
use (nothing in core needs it), but we're not yet ready to commit
to it being a stable API that would receive no breaking changes or
be removed without deprecation.

The appropiate tag for such experimental feature that allows early
adoption (with caution, knowing it might get renamed, moved or dropped
in the next major release) – is @unstable.
<https://www.mediawiki.org/wiki/Stable_interface_policy>

Bug: T247862
Change-Id: Iceaaf520979afa1c3ee806262083f94d67660174
2020-07-02 02:04:02 +01:00
jenkins-bot
cd91918405 Merge "Revert "OutputPage: Temporary hack to avoid taint-check crash"" 2020-06-26 16:25:56 +00:00
Daimona Eaytoy
a77226d105 Revert "OutputPage: Temporary hack to avoid taint-check crash"
This reverts commit dad17c82da.

Reason for revert: now working with newer taint-check.

Change-Id: I394c04b5583f718d5d809fdd15ae723b1564d551
2020-06-26 09:33:33 +00:00
jenkins-bot
a7dae830b3 Merge "Introduce wfDeprecatedMsg()" 2020-06-22 22:30:49 +00:00
jenkins-bot
a0559c63c6 Merge "Deprecate using Skin method to add body attributes." 2020-06-22 21:23:10 +00:00
Tim Starling
d459add63d Introduce wfDeprecatedMsg()
Deprecating something means to say something nasty about it, or to draw
its character into question. For example, "this function is lazy and good
for nothing". Deprecatory remarks by a developer are generally taken as a
warning that violence will soon be done against the function in question.
Other developers are thus warned to avoid associating with the deprecated
function.

However, since wfDeprecated() was introduced, it has become obvious that
the targets of deprecation are not limited to functions. Developers can
deprecate literally anything: a parameter, a return value, a file
format, Mondays, the concept of being, etc. wfDeprecated() requires
every deprecatory statement to begin with "use of", leading to some
awkward sentences. For example, one might say: "Use of your mouth to
cough without it being covered by your arm is deprecated since 2020."

So, introduce wfDeprecatedMsg(), which allows deprecation messages to be
specified in plain text, with the caller description being optionally
appended. Migrate incorrect or gramatically awkward uses of wfDeprecated()
to wfDeprecatedMsg().

Change-Id: Ib3dd2fe37677d98425d0f3692db5c9e988943ae8
2020-06-22 14:34:39 +10:00
Ammar Abdulhamid
18263d95b8 Deprecate using Skin method to add body attributes.
- Remove the parent method. There's no skin that's relying on this method
directly and since it's no-op declaration, removing it is also no-op.
- Raise deprecation warning if the body attributes are modified with the
method (as implemented by the relevant skin that made call to the OutputPage)
- The recommended way to add body attributes now is to use the
OutputPageBodyAttributes hook

Bug: T255698
Depends-On: Idab13c37002ac5663f292e4f4b4ff51eb7573fda
Change-Id: Ibc56bf40c1ea70b2d7f7860ed85fbeb7b5d2bbf5
2020-06-21 08:19:35 +01:00
Lucas Werkmeister
5ba809c214 Clarify that addModuleStyles is for style-only modules
“the styles of … ResourceLoader modules” suggests to me that this method
can be used with any ResourceLoader module(s), and their style parts
will be loaded as <link rel=stylesheet> while JavaScript parts will load
as usual, but this is not in fact the case: if ResourceLoaderClientHtml
encounters a module type other than LOAD_STYLES in the moduleStyles
modules, it logs an error and skips the module.

Change-Id: If0e709311c1b777f6d99cb714f19307c1015ec01
2020-06-19 17:29:48 +02:00
Lucas Werkmeister
a340fe20e9 Fix method name in comment
There is no addMetaLink() method; I assume it’s meant to be addMeta().

Change-Id: I4f59d5dd96d3a59522fbc7cf38badc93698e29fa
2020-06-08 12:35:36 +02:00
DannyS712
f3bcc94bcf Deprecate User::getNewMessageRevisionId
Uses User::getNewMessageLinks, which uses Revision objects
Only caller updated to use a new private method

Bug: T253949
Change-Id: I04c0558916e7216540dd7bd12a2a391a1ed7660a
2020-06-05 21:36:06 +00:00
Tim Starling
47a1619027 Remove terminating line breaks from debug messages
A terminating line break has not been required in wfDebug() since 2014,
however no migration was done. Some of these line breaks found their way
into LoggerInterface::debug() calls, where they mess up the formatting
of the debug log.

So, remove terminating line breaks from wfDebug() and
LoggerInterface::debug() calls.

Also:
* Fix the stripping of leading line breaks from the log header emitted
  by Setup.php. This feature, accidentally broken in 2014, allows
  requests to be distinguished in the log file.
* Avoid using the global variable $self.
* Move the logging of the client IP back to Setup.php. It was moved to
  WebRequest in the hopes that it would not always be needed, however
  $wgRequest->getIP() is now called unconditionally a few lines up in
  Setup.php. This means that it is put in its proper place after the
  "start request" message.
* Wrap the log header code in a closure so that variables like $name do
  not leak into global scope.
* In Linker.php, remove a few instances of an unnecessary second
  parameter to wfDebug().

Change-Id: I96651d3044a95b9d210b51cb8368edc76bebbb9e
2020-06-03 12:01:16 +10:00
Daimona Eaytoy
dad17c82da OutputPage: Temporary hack to avoid taint-check crash
Bug: T254079
Change-Id: Ic4dbba20d5be43d49a39f6a09a734fab6722c44f
2020-05-31 12:04:13 +02:00
Tim Starling
68c433bd23 Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.

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

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

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

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

Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-05-30 14:23:28 +00:00
MusikAnimal
9d3254d18e OutputPage: add @internal annotation to addHtmlClasses()
Follow-Up: I4b994e081d9582801fe9d198efd68afc46a14703
Change-Id: I938bfc21d38981c307a87889ef353ddd21a04791
2020-05-26 18:15:02 +00:00
suecarmol
b32e71aa60 Ajax watch: Move JS config var to packageFiles
To improve performance, the watchlist expiry flag was moved to
packageFiles instead of the OutputPage.php file

Bug: T249259
Change-Id: If57030db7d1e90b0890ee2a1ad466772a2f8b8bc
2020-05-22 19:21:45 -05:00
MusikAnimal
168e23e80a OutputPage: fix @since version
Change-Id: I1880ed04237cadec5ea9e3abde15b21d004208f8
Follow-Up: I4b994e081d9582801fe9d198efd68afc46a14703
2020-05-13 17:12:29 -04:00
suecarmol
6224ffd03c Replace toast with OOUI popup on watchlist message
When watching a page, a toast appears with a message to confirm it has been
watched/unwatched successfully. This replaces the toast with a OOUI popup.

Bug: T249259
Change-Id: Ib1b8e31ce8e6fe271cb0d6e5fbaf80bc65360da1
2020-05-06 19:53:22 -05:00
MusikAnimal
36d2a5b88f OutputPage: allow additional CSS classes to be added to <html>
In some cases CSS classes must be on the <html> element and not the
<body>. An example is the DarkMode extension. Due to how the stacking
context works, the CSS `invert()` filter must be on <html>. We can't use
JavaScript to apply the styles because there would be a brief delay
after page load before the JS runs, causing a flashing effect.

Bug: T241925
Change-Id: I4b994e081d9582801fe9d198efd68afc46a14703
2020-04-28 11:46:45 -07:00
C. Scott Ananian
85e1525862 Deprecate ParserOptions::getTidy() and ParserOptions::setTidy()
These options no longer have any effect.

Bug: T198214
Change-Id: Icc3eaed7ab8a3070c4339b272d580328ba40912d
2020-04-19 22:53:39 -07:00
Dave Pifke
0a3aa08b72 OutputPage: Add experimental preconnect resource hint for thumbnails
Adds <link rel="preconnect"> for the first valid foreign or local file
repo, on pages containing images.

This is a hint to the browser that it should open a connection to the
other host (e.g. upload.wikimedia.org), if it doesn't have one
already.  Doing so allows the connection setup to happen before page
parsing is complete, and should result in faster image loading,
especially on slow connections.

Bug: T123582
Change-Id: I2dcc14f05012570a3e41ed8c7064969a4cbfb6db
2020-04-07 21:04:47 +00:00
Thiemo Kreuz
1006aa41e6 Fix mismatching type hints in PHPDoc tags
This is a collection of random bits from my local stashes. This patch
intentionally only touches comments, no code.

Notably:
* Use more specific string[] instead of array, if possible.
* Some comments mention "or null", but miss to list the type.

Change-Id: I712b28964f125c8e3dcb4e3fb993757a09f96644
2020-03-24 09:59:02 +01:00
Roan Kattouw
f160f71823 OutputPage: Fix warning when setting wgUserNewMsgRevisionId
Follow-up to e08e9609ff, which contained a
typo ($$ instead of $)

Bug: T248049
Change-Id: I7206cb61a61cad528ece880cffcbdd7b4e04e935
2020-03-18 20:27:14 -07:00
Timo Tijhof
e1c88d2fcb resourceloader: Merge 'user.tokens' module into 'user.options'
For back-compat, keep 'user.tokens' as deprecated alias to 'user.options'
for one release cycle (to be removed in MW 1.36).

== user.options ==

As before, 'user.options' arrives immediately on every page view,
embedded in the HTML. It has an async dependency on 'user.defaults',
which is not downloaded until there is a known demand on
'user.options'. Once that arrives, the implementation closure
of 'user.options' will execute, and the module becomes 'ready'.

== user.options "empty" ==

Before this change, UserOptionsModule used isKnownEmpty to consider the
module "empty" for logged-out users (as well as for logged-in users that
haven't yet set any preferences).

This was a mistake. It is invalid in ResourceLoader to mark a module as
"empty" if that module has dependencies (see also T191596 and c3f200849).

This broke the state machine. The impact was minimal given that it is unlikely
for features to read keys from mw.user.options for logged-out users, which
if attempted would have simply returned null for all keys.

== New HTML ==

The user.options module is always embedded (never empty), and always
has a dependency on user.defaults.

== Cached HTML ==

The cached HTML for anons sets user.options's state to ready without
waiting for any dependency. Per the above, this was already causing
subtle bugs with mw.user.options.get() likely returning null for anons,
which was fairly innocent. For tokens a bottom value of null would be
problematic as the default for tokens must be "+\" instead. To make
sure that is available for cached page views, set this directly
in mediawiki.base.js. The cached HTML does contain an implement call for
'user.tokens' that contains the same defaults, but new code will not
be asking for or waiting for user.tokens, so that is unused.

Bug: T235457
Change-Id: I51e01d6fa604578cd2906337bde5a4760633c027
2020-03-17 20:51:15 -07:00