If the Title object isn't the title of the current viewed WikiPage, the page_lang
field of the database isn't requested. This results in the problem, that
Title::getPageLanguage() always returns the default content language, even if
the page language is different (changed with Special:PageLanguage, if
wgPageLanguageUseDB is true). That is problematic for the Translate extension,
which relies on the correct page language.
This change makes sure, that getPageLanguage() always return the correct page
language. If the page language isn't loaded already, Title::getPageLanguage()
now does a database lookup (if $wgPageLanguageUseDB is true) to get the correct
page language. It will use LinkCache for the page_lang field.
Bug: T121666
Change-Id: I0ae5ea39f7a124ed427ca5dfb26c1a116b27a94e
The plan here is to take it out of 1.27.0-wmf.12 and put it back in
1.27.0-wmf.13.
Since BotPasswords depends on SessionManager, that's getting temporarily
removed too.
This reverts the following commits:
* 6acd424e0d SessionManager: Notify AuthPlugin before calling hooks
* 4d1ad32d8a Close a loophole in CookieSessionProvider
* fcdd643a46 SessionManager: Don't save non-persisted sessions to backend storage
* 058aec4c76 MessageCache: Don't get a ParserOptions for $wgUser before the end of Setup.php
* b5c0c03bb7 SessionManager: Save user name to metadata even if the user doesn't exist locally
* 13f2f09a19 SECURITY: Fix User::setToken() call on User::newSystemUser
* 305bc75b27 SessionManager: Don't generate user tokens when checking the tokens
* 7c4bd85d21 RequestContext::exportSession() should only export persisted session IDs
* 296ccfd4a9 SessionManager: Save 'persisted' flag in session metadata
* 94ba53f677 Move CSRF token handling into MediaWiki\Session\Session
* 46a565d6b0 Avoid false "added in both Session and $_SESSION" when value is null
* c00d0b5d94 Log backtrace for "User::loadFromSession called before the end of Setup.php"
* 4eeff5b559 Use $wgSecureCookie to decide whether to actually mark secure cookies as 'secure'
* 7491b52f70 Call session_cache_limiter() before starting a session
* 2c34aeea72 SessionManager: Abstract forceHTTPS cookie setting
* 9aa53627a5 Ignore auth cookies with value 'deleted'
* 43f904b51a SessionManager: Kill getPersistedSessionId()
* 50c5256352 SessionManager: Add SessionBackend::setProviderMetadata()
* f640d40315 SessionManager: Notify AuthPlugin when auto-creating accounts
* 70b05d1ac1 Add checks of $wgEnableBotPasswords in more places
* bfed32eb78 Do not raise a PHP warning when session write fails
* 722a7331ad Only check LoggedOut timestamp on the user loaded from session
* 4f5057b84b SessionManager: Change behavior of getSessionById()
* 66e82e614e Fix typo in [[MediaWiki:Botpasswords-editexisting/en]]
* f9fd9516d9 Add "bot passwords"
* d7716f1df0 Add missing argument for wfDebugLog
* a73c5b7395 Add SessionManager
Change-Id: I2389a8133e25ab929e9f27f41fa9a05df8147a50
Until Setup.php completes, we can't access the "current" user and trying
to do so logs a warning. So don't try.
Bug: T124367
Change-Id: If31230407829c04f34d9cfefcbb97edacb949b6d
The functionality for marking a debug log message for delivery to a log
file but not to MWDebug was removed in 1.25 with the introduction of
the PSR-3 logging system. Convert the messages that were marked for this
special handling in a7a0883 to use 'private' instead.
Bug: T122644
Change-Id: Iefaac07a5922c16c2899904c7b678199c5b1efe9
This overrides the message being sent. Use 'messageKey' instead,
which complements 'cacheKey' used elsewhere in the class.
Change-Id: I70b1115853d16e5f1357dc5f3d10e46f9c029fc6
MessageBlobStore class:
* Make logger aware.
* Log an error if json encoding fails.
* Stop using the DB table. WANObjectCache supports everything we need:
- Batch retrieval.
- Invalidate keys with wildcard selects or cascading check keys.
* Update tests slightly since the actual update now happens on-demand as
part of get() instead of within updateMessage().
ResourceLoader class:
* Remove all interaction with the msg_resource table. Remove db table later.
* Refactor code to use a hash of the blob instead of a timestamp.
Timestamps are unreliable and roll over too frequently for message blob store
because there is no authoritative source. The timestamps were inferred based on
when a change is observed. Message overrides from the local wiki have an
explicit update event when the page is edited. All other messages, such as
from MediaWiki core and extensions using LocalisationCache, have a single
timestamp for all messages which rolls over every time the cache is rebuilt.
A hash is deterministic, and won't cause needless invalidation (T102578).
* Remove redundant pre-fetching in makeModuleResponse().
This is already done by preloadModuleInfo() in respond().
* Don't bother storing and retreiving empty "{}" objects.
Instead, detect whether a module's message list is empty at runtime.
ResourceLoaderModule class:
* Make logger aware.
* Log if a module's message blob was not preloaded.
cleanupRemovedModules:
* Now that blobs have a TTL, there's no need to prune old entries.
Bug: T113092
Bug: T92357
Change-Id: Id8c26f41a82597e34013f95294cdc3971a4f52ae
Previously, logged-out users either only saw "Create account" and "Log in"
links in the personal area, or if $wgShowIPinHeader was true, they saw
[icon] 127.0.0.1 Talk for this IP address Create account Log in
where the IP address itself linked to the IP user page.
Now, logged-out users by default see the following:
[icon] Not logged in Talk Contributions Create account Log in
The old $wgShowIPinHeader feature is removed. It is very unfriendly to
show the user's IP address (in red, no less) at the top of every page,
since this will mean nothing to most visitors. Caching means that this
can't even be done reliably, anyway.
Another improvement is that the "talk" and "contributions" links are not
shown if anonymous users don't have the 'edit' right.
Modelled after the loggedOutTalkPage() function at Dutch Wikipedia
<https://nl.wikipedia.org/w/index.php?oldid=44706954>
Bug: T112724
Change-Id: I6f44e3e5d97ea917e4a03af47f3795792e4ca122
* Also added getBlob() and getBlobs() methods. These don't
require passing ResourceLoader as argument.
In preparation for T113092.
Change-Id: I3239c45f0243eca1eaf85bc53fca736e4c9a209c
The $ucfirst and $wgContentLang variables are not used by get().
Keep these inside getMessageFromFallbackChain() instead.
Also add mark getMsgFromNamespace() as public since it is used
in other places in core and by extensions.
Change-Id: I83bf77c17aa46f3929f89c4af97693611761629b
* Update and improve class documentation.
* Remove comment that claims to return false if the module has no message.
generateMessageBlob() returns '{}' in that case. And this is expected since
we want to cache the absence of messages.
* Re-use the module objects passed to MessageBlobStore::get() in getFromDB()
instead of using ResourceLoader::getModule(). The object is the same either
way (since ResourceLoader re-uses the objects also) but reduces complexity
of getFromDB() to not need the ResourceLoader object as parameter.
Change-Id: I89a14d7185877fae52791f6837883ed3a6749cd7
Language::ucfirst() already has this optimisation. The expensive
method is Language::uc(), which is only called when needed.
The ord() < 128 is one of the conditionals in Language::ucfirst().
Change-Id: Idd648b7b84eba1f92dda904438122fe38d3cf22b
Follows-up af89b09a06 and e40a90f0bc, and general phasing out
of MapCacheLRU and ProcessCacheLRU.
Use of ProcessCacheLRU seems redundant in this case as it is
essentially just a keyed singleton.
Change-Id: I7cc84cf6c76ecc422ea337dba2d216c3d7ebf281
In preparation for conversion from MapCacheLRU to HashBagOStuff.
* Use early-return pattern for error and rejection cases.
* Add 'int' to @return for getGoodLinkFieldObj() per the
values set in addGoodLinkObj().
* Add type hints for Title where possible.
* Avoid single-letter variables like $f and $s.
* Add visibility for public static methods.
Change-Id: Iab90539922f648c21cb147f749943a64f598e8de
* This avoids throwing atomic section errors when recache()
is triggered in the middle of transactions.
* Also made the read-only checks handle $wgReadOnly mode.
Change-Id: Ie00cf8454656a6dc3b1862475a959b2af3b472f0
This table is not needed because module names and their messages
array are available to the runtime environment at very little cost.
The only purpose it was serving is reverse lookup from message
key to module name (e.g. when MessageCache receives update that
need to propagate to MessageBlobStore). However that is better
achieved by simply looping through modules in PHP. The overhead
of a database is not worth this minor convenience.
MessageBlobStore
* insertMessageBlob: Doesn't need to update msg_resource_links.
* updateModule: Doesn't need to update msg_resource_links.
* getUpdatesForMessage: Reimplement with list from memory
instead of msg_resource_links.
The database table will be removed in If009e2620e59002e1.
Bug: T113092
Change-Id: Ia9131f570001f00c9800b260ac4b3469d54d2784
When the LocalisationCache class is set to 'detect', we prefer LCStoreCDB if
$wgCacheDirectory is set, but we default to LCStoreDB otherwise. Rather than
give up, we should try wfTempDir(), since any directory that meets its criteria
is also suitable for LCStoreCDB.
Change-Id: Id3e2d2b18ddb423647bf2e893bcf942722c0e097
Deprecated since MediaWiki 1.26 (32d1017e7d). These methods contain the
only remaining callers of MapCacheLRU::getAllKeys() which is the only odd
method of MapCacheLRU not supported by BagOStuff.
Change-Id: I64e054803595d49a5bd779accc94353924f7d87d
The $mForUpdate flag no longer causes the FOR UPDATE option to be added.
This was at first only true for some values of $wgAntiLockFlags (since
r9248 / ba8a00bcb833), though since 12757b50f8 (when the setting was
removed), is always the case.
The added text is based on the description for $wgAntiLockFlags.
Change-Id: I02a3e2df37ec40c7e36ae6210c8263f13d9e3e5b
CacheEpoch isn't meant for this (it's meant for page cache), I can't
imagine a scenario in which we'd want to bump that to invalidate
MessageBlobStore. It should be standalone and can be easily cleared
if needed by truncating the relevant table (it's automatically
repopulated).
This also removes wfTimestamp/DateTime overhead.
Change-Id: Iab06edbf71f20f3430207a80df90131c79dc03a7
These callers don't need to do purges, but can still perfectly
take advantage of this instance over a plain BagOStuff. Namely:
* Replication and snapshot lag awareness
* Preemptive regeneration
* Easy process cache support
The idea is for there to only be one caching class/factory
to use, instead of having rules for picking which one to use.
Change-Id: I8e362df451c0c28731fc853c044c4c4b8e097f01
LocalisationCache was added in 1.16, so in order to retain PHP 5.1
compatibility, array_fill_keys() was avoided. In 1.17, support for
PHP 5.1 was dropped, so we can use that function now.
Change-Id: I435705639f1a470324a4ba46153351aadc0d40e2