Commit graph

390 commits

Author SHA1 Message Date
jenkins-bot
40a628a501 Merge "Add type hint against LinkTarget" 2016-02-26 18:13:14 +00:00
Leszek Manicki
0e5a1f8879 Add type hint against LinkTarget
A follow up to I132f254536a7516e878e20ad49d2f415796c4490

Change-Id: I74bff64e86ea95cecddf504e532543aa74b79775
2016-02-25 18:21:02 +01:00
Niklas Laxström
5b33f0fca1 Allow ­ in messages
Bug: T127062
Change-Id: I8b89d8fd6f688a2fa60f3bd92e4cea6909ed267f
2016-02-17 12:45:36 +01:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Florian
d237380021 Fix not-loaded DbPageLanguage when Title::getPageLanguage() get's called
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
2016-02-16 20:37:40 +00:00
jenkins-bot
87d3bd7afc Merge "Use LinkTarget in LinkBatch::addObj" 2016-02-11 03:49:50 +00:00
Brad Jorsch
35c38ce319 Add User::isSafeToLoad() and ParserOptions::newFromAnon()
Useful for avoiding "User::loadFromSession called before the end of
Setup.php".

Bug: T124367
Change-Id: I0b018a623fc833ca95d249ee21667a8f5690d50e
2016-02-03 21:45:56 +00:00
Brad Jorsch
2257fe4228 Revert "Remove SessionManager, temporarily"
This reverts commit 823db5d63dd5200d04c63da50ba6bf16f928e70b.

Change-Id: Ibb3e023e4eb6715295586dea87d0725c344a8271
2016-02-03 21:44:59 +00:00
addshore
cc425ece7b Use LinkTarget in LinkBatch::addObj
Change-Id: I132f254536a7516e878e20ad49d2f415796c4490
2016-02-03 16:17:38 +01:00
Brad Jorsch
5083e810eb Remove SessionManager, temporarily
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
2016-02-01 22:06:49 +00:00
Brad Jorsch
058aec4c76 MessageCache: Don't get a ParserOptions for $wgUser before the end of Setup.php
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
2016-01-29 14:30:25 -05:00
addshore
8f4ce04107 LinkBatch::addObj can also work with TitleValue objs
Change-Id: I035d38a5eb8299fcce9cc0efa3952e391b325722
2016-01-26 20:04:28 +01:00
Bryan Davis
0affda7edf Remove use of $dest = 'log' for wfDebugLog
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
2015-12-30 13:03:14 -07:00
jenkins-bot
ea9fcc1e4d Merge "Merge namespace aliases like we merge namespace names" 2015-12-17 19:03:48 +00:00
This, that and the other
1783ae651c Merge namespace aliases like we merge namespace names
To avoid problems like T60074 and deal with requests like T101634.

Bug: T108427
Change-Id: I3ef6bbcc820a254b44ba86bfccb3854983a19ff6
2015-12-15 16:53:28 +11:00
Timo Tijhof
8326c1f860 resourceloader: Avoid using 'message' in log message key
This overrides the message being sent. Use 'messageKey' instead,
which complements 'cacheKey' used elsewhere in the class.

Change-Id: I70b1115853d16e5f1357dc5f3d10e46f9c029fc6
2015-12-10 01:33:25 +00:00
Timo Tijhof
5d5b269e0e resourceloader: Migrate from msg_resource table to object cache
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
2015-12-08 14:02:38 +00:00
This, that and the other
ea335eb55d Improved personal toolbar for logged-out users
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
2015-12-01 18:44:52 +00:00
Timo Tijhof
a4fa0229c1 Add unit tests for MessageBlobStore
* Also added getBlob() and getBlobs() methods. These don't
  require passing ResourceLoader as argument.
  In preparation for T113092.

Change-Id: I3239c45f0243eca1eaf85bc53fca736e4c9a209c
2015-11-21 00:09:47 +00:00
Timo Tijhof
53bfdc624d MessageCache: Remove $ucfirst and clean up getMessageFromFallbackChain()
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
2015-11-17 18:41:10 +00:00
Timo Tijhof
4020bf947b resourceloader: Update MessageBlobStore documentation and code cleanup
* 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
2015-11-13 00:41:57 +00:00
Timo Tijhof
976f43327d resourceloader: Remove deprecated MessageBlobStore::getInstance()
Deprecated since MediaWiki 1.25.
Not used anywhere in public Wikimedia Git.

Change-Id: Iaa31d0e83b95fb033c62430bc3fc4dd66af16906
2015-11-12 00:24:38 +00:00
Timo Tijhof
e53bf8bdcb resourceloader: Log if MessageBlobStore failed to fetch a message
Bug: T93800
Change-Id: I6f174251a6b9a6b31921037f672dbc197f3abb7e
2015-11-10 04:40:31 +00:00
Timo Tijhof
2d3ea7996f MessageCache: Remove redundant Language::ucfirst() optimisation
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
2015-11-10 00:41:45 +00:00
Timo Tijhof
e6205019a4 BacklinkCache: Remove use of ProcessCacheLRU
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
2015-11-10 00:06:09 +00:00
Timo Tijhof
03a620004b LinkCache: Convert from MapCacheLRU to HashBagOStuff.
Change-Id: I28a9509ad4c6d724a12dc72bc50d3cf58642c651
2015-11-09 23:17:47 +00:00
Timo Tijhof
dcf8ec0283 LinkCache: Minor clean up of documentation and variable names
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
2015-11-09 23:17:43 +00:00
jenkins-bot
0bb4b4312e Merge "Convert LCStoreDB to using startAtomic/endAtomic" 2015-11-09 20:08:02 +00:00
Aaron Schulz
ef9f0ed8a1 Convert LCStoreDB to using startAtomic/endAtomic
* 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
2015-11-09 19:54:07 +00:00
Timo Tijhof
70f8a31afe resourceloader: Remove use of msg_resource_links table
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
2015-11-09 19:16:38 +00:00
Ori Livneh
36171312ef LocalisationCache: try harder to use LCStoreCDB
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
2015-11-05 17:48:05 -08:00
Aaron Schulz
ac1325aa43 Improve BacklinkCache field docs
Change-Id: I8303d5577ac84b8882e5ad79ac3058d6bf49356f
2015-11-03 02:56:30 -08:00
Timo Tijhof
8b463047a9 LinkCache: Remove deprecated getBadLinks and getGoodLinks methods
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
2015-11-03 06:08:36 +00:00
jenkins-bot
dad19d999c Merge "Convert SiteStatsUpdate to using getMainStashInstance()" 2015-11-02 22:47:10 +00:00
Aaron Schulz
17c91ad610 Replace newAccelerator() with getLocalServerInstance()
The name is clearer and more consistent, with simpler arguments.

Change-Id: I7205a99ce033e8b086a52cd02c8a721e99c84b1e
2015-11-02 21:39:08 +00:00
Aaron Schulz
6cc65335f3 Convert SiteStatsUpdate to using getMainStashInstance()
Also fixed various $wgMemc related comments

Change-Id: I20602b672f724c8df1e82bbe3c586cb899a54640
2015-10-31 13:05:03 -07:00
Kevin Israel
eb8d6eb754 Update description of LinkCache::forUpdate()
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
2015-10-30 06:09:29 -04:00
jenkins-bot
f84ebddc13 Merge "Convert buildSidebar() to using getWithSetCallback()" 2015-10-29 08:04:32 +00:00
Aaron Schulz
141197dd27 Convert buildSidebar() to using getWithSetCallback()
Change-Id: Id9a27ba2bbd3aceee26bf35844d1c970dbb32d47
2015-10-28 18:24:31 -07:00
Timo Tijhof
afcfc3290c resourceloader: Consistently refer to the framework as ResourceLoader
Change-Id: Ia59e4eac9662723e80d62f7cfcb9e4292e3ee4de
2015-10-28 03:24:40 +00:00
Aaron Schulz
92bbfd5ea6 Migrate more callers away from $wgMemc
Callers should use more expliciy lazy-loaded
cache factory methods.

Change-Id: Ifa0bf389720a09a931ee6466b993f787d83a09a7
2015-10-26 19:07:12 +00:00
Timo Tijhof
445136b5bf resourceloader: Remove CacheEpoch from MessageBlobStore::getFromDB
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
2015-10-21 02:40:06 +00:00
Aaron Schulz
4f781c7bf9 Convert some users to WANObjectCache for consistency
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
2015-10-19 16:46:52 +00:00
Timo Tijhof
68a54d6d7a objectcache: Rename WANObjectCache TTL_NONE to TTL_INDEFINITE
"None" has a somewhat unobvious meaning, also ambiguous with "uncachable".

Change-Id: I799de385427aeb8f581d51800606552bdc998252
2015-10-14 17:08:59 -04:00
Kevin Israel
fd7a480402 LocalisationCache::recache(): Use array_fill_keys()
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
2015-10-08 16:29:16 -04:00
jenkins-bot
1569779421 Merge "Update various @params from DatabaseBase to IDatabase" 2015-10-05 19:59:21 +00:00
Thiemo Mättig
56d2a644f7 Add null to @return tags if a method can return null
Change-Id: I420998351663d92c4a101f61842e40591eebcd5f
2015-10-05 17:53:13 +02:00
Aaron Schulz
0f7893f877 Update various @params from DatabaseBase to IDatabase
Change-Id: I98e44cdffb0fc0d729f69f702799139afb988c20
2015-10-05 05:24:29 +00:00
Siebrand Mazeland
4e582a507d Fix 3 PHPCS warnings in MessageCache.php
Change-Id: I0970b8844fa89d3bdc4fec200d912ecf80a52176
2015-09-28 13:18:54 +02:00
Kevin Israel
3f516b5139 Remove unused private property LinkCache::$mClassVer
This was added in r2084 / c280ef342b for a "persistent link cache"
feature, which became obsolete in 1.4 and was removed in 1.5.

https://www.mediawiki.org/wiki/Manual:$wgEnablePersistentLC

Follows-up r9276 / cb45389b9c.

Change-Id: I2f27d6acc1a1f9a9382a47d56921f570107a7be9
2015-09-25 07:54:02 -04:00