Commit graph

478 commits

Author SHA1 Message Date
mdew192837
299255c648 MessageCache: Avoid deprecated wfMemcKey()
Change-Id: I31e3cde0a94e355de9f32a17636aaf54aa2d40c4
2017-05-24 14:15:29 -05:00
Kunal Mehta
3e896060b5 FileCacheBase: Avoid deprecated wfMemcKey()
Change-Id: I5476bf45deb55ef4ff158970102b1ce17d3fee29
2017-05-23 15:08:25 -07:00
Brad Jorsch
6efee6f0db MessageCache: Avoid 'contributions' replicas
On WMF wikis, the partitioning of the revision table on the
'contributions' replicas makes the query here perform really poorly.
Specify 'api' as a hack for now to avoid those replicas.

This query happens once per day per wiki, plus when someone edits the
MediaWiki namespace, so it shouldn't be much additional load.

Bug: T164666
Change-Id: I5ae74d1702144f6475e9cfb13effc43389d66233
2017-05-08 14:00:26 -04:00
Brad Jorsch
f0a80ea778 Prettify MessageCache::loadFromDB()-small query
Adjust the call so it uses JOIN...ON syntax rather than comma joins.

Bug: T164666
Change-Id: I93c8569620d543e9507d0adf1283443915f50d4b
2017-05-08 13:57:13 -04:00
Brad Jorsch
1aac0a2992 Wrap parser output in <div class="mw-parser-output">
This will allow CSS to target just the parser output, without also
accidentally targeting the edit form, diff tables, and so on.

Bug: T37247
Change-Id: If4eb5bf71f94fa366ec4eddb6964e8f4df6b824a
Depends-On: I330c6aa4aaee045614b1801ed34bc9e03be69650
Depends-On: I52a518fa44e017841fe78474012cd69823e0a41d
2017-05-08 05:32:03 +00:00
Aaron Schulz
33bc3e7dfb Use makeKey() in BacklinkCache
Change-Id: I23c000c8c2c77aa538fe258ea34eb764987eb52d
2017-04-20 12:26:23 -07:00
Aaron Schulz
dd359741cc Move DB errors to Rdbms namespace
Change-Id: I463bd86123501abc68fdb78b4cda6110f7af2549
2017-04-15 10:47:41 -07:00
Aaron Schulz
d735dc562d Move Database and subclasses to Rdbms namespace
Change-Id: I52bef87512f9ddd155d1f4cc0052f6b7a0db5b42
2017-04-12 10:43:57 -07:00
Reedy
b2301ab354 SECURITY: Don't write LocalisationCache to temporary directory
Bug: T161453
Change-Id: I51b375c63fcece908da921c465c861968c9eee1c
2017-04-06 13:43:47 -07:00
Aaron Schulz
345616cc5e Avoid duplicate key generation code in MessageCache
Also explain the use of !NONEXISTANT in the comments a bit more.

Change-Id: Ib087df9bf31023e7acaf2116e74b2dfeda10c9d2
2017-04-05 23:16:16 -07:00
Timo Tijhof
1c200d7682 resourceloader: Complete code coverage for MessageBlobStore
Change-Id: I6269843ed51c67bf2d300eb58a613122ffdae740
2017-03-31 17:58:43 -07:00
jenkins-bot
8e8b4167ce Merge "SECURITY: Disable <html> tag on system messages despite $wgRawHtml = true;" 2017-03-31 05:10:22 +00:00
Aaron Schulz
488a647831 Move IDatabase/IMaintainableDatabase to Rdbms namespace
Change-Id: If7e8a8ff574661fd827de8bcec11d2c39a687300
2017-03-28 15:32:38 -07:00
Brian Wolff
1c7889446d SECURITY: Disable <html> tag on system messages despite $wgRawHtml = true;
System messages may take parameters from untrusted sources. This
may include taking parameters from urls given by unauthenticated
users even if the wiki is a read-only wiki. Allowing <html> tags
in such a context seems like an accident waiting to happen.

Bug: T156184
Change-Id: I661f482986d319cf41da1d3e7b20a0f028a42e90
2017-03-28 21:51:44 +00:00
Aaron Schulz
c2bbb51c20 Make MessageCache use the immutable text cache during cache rebuilds
Only 1 message typically changed per run, so for wikis using
external storage and with many customized messages, this can
make rebuilds considerably faster.

Bug: T158084
Change-Id: Ib668e69a207e3fbeb7871f2f6a102ff1af567368
2017-03-08 20:42:22 -08:00
Timo Tijhof
50a035cd6b Clean up get_class($this) -> static::class in /includes/cache and /includes/libs
* get_class()        -> __CLASS__ (same as self::class)
* get_called_class() -> static::class
* get_class($this)   -> static::class

Change-Id: I22c62851bcc88405f4bdd77258d6e28ec1a14924
2017-03-07 21:06:06 +00:00
Timo Tijhof
2e288bdccf resourceloader: Remove useless INFO log for message blob cache-miss
Change-Id: I306fe87a1de5335e4ce7042667a005bbd7d772c1
2017-03-06 12:42:40 -08:00
Aaron Schulz
e01fd44388 Move ResultWrapper subclasses to Rdbms
Change-Id: I6f3f0e85e268b24c57c537aa6ad8016e0b4cdddb
2017-03-03 00:44:41 +00:00
James D. Forrester
9635dda73a includes: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: I6f59febaf8fc96e80f8cfc11f4356283f461142a
2017-02-21 18:13:24 +00:00
Aaron Schulz
44ac0de8d1 Set mCache in the second MessageCache::loadFromDatabase() caller
The member variable is needed in the next lines, which previously
just used the array with "LATEST" set and would be seen as invalid
and discarded next time.

Bug: T157033
Change-Id: I5b84b1ae4a9c7b710ee452c61d7d9d6076ec9e6a
2017-02-02 14:06:33 -08:00
addshore
af95474b62 Remove HTMLFileCache::newFromTitle()
Change-Id: I0076801aa7b9af5083c5a7a66f2d1c9884b70ee9
2017-01-28 17:31:18 +00:00
Aaron Schulz
2e5eb693de objectcache: add WANObjectCacheReaper for assuring purges
* This fixes keys based on some sort of change log.
  Updates are wrapped in a mutex and keep track of the
  last known good position.
* Make WANObjectReapUpdate class that cleans up title
  related keys using the recentchanges table. This triggers
  as a deferred updates on RC view.

Change-Id: I7f14b9ca2533032147e62b1a3cc004a23da86579
2017-01-27 02:21:06 +00:00
jenkins-bot
b550816009 Merge "Inject remaining cache objects into MessageCache" 2017-01-26 03:30:00 +00:00
Aaron Schulz
c962b48056 Avoid races in MessageCache::replace()
Do the process cache update immediately (as before) but push
the shared cache updates to a deferred update. This update
will thus start with a clear transaction snapshot, so it can
acquire the lock before the first SELECT as is proper.

Also added some missing method visibilities.

Bug: T144952
Change-Id: I462554b300d4688b09ab80cd1bb8a4340ffaa786
2017-01-25 00:46:41 +00:00
Aaron Schulz
e99b863eec Inject remaining cache objects into MessageCache
Change-Id: I431d6e9b443a00fdc1b65adb90ae9de496242f81
2017-01-21 06:23:40 +00:00
Jack Phoenix
38c0e0410a Pass the language code to the MessagesPreLoad hook
So that extensions like MessageCommons can try to use this (and
$wgLanguageCode) instead of $wgLang->getCode()/$wgContLang->getCode(), as
the latter ones cause fatals and recursion, at least with the Gadgets
extension also enabled at the same time.

Change-Id: If71fe1ded26c7a1c771128397783783ad5715b00
2017-01-08 02:34:22 +02:00
jenkins-bot
9ac29c74ed Merge "Cleanup some incorrect return annotations" 2016-12-16 07:22:24 +00:00
jenkins-bot
1676448145 Merge "MessageCache invalidation improvements" 2016-12-15 22:18:31 +00:00
Erik Bernhardson
d67197fa11 Cleanup some incorrect return annotations
Most of these are simply changing annotations to reflect
reality. If a function can return false to indicate failure
the @return should indicate it.

Some are fixing preg_match calls, preg match returns 1, 0 or false,
but the functions all claim to return booleans.

This is far from all the incorrect return types in mediawiki, there
are around 250 detected by phan, but have to start somewhere.

Change-Id: I1bbdfee6190747bde460f8a7084212ccafe169ef
2016-12-12 10:15:05 -08:00
Aaron Schulz
cd7ab52a4a MessageCache invalidation improvements
Re-submission of 9339a08b7.

* Increase time range for getValidationHash() using "latest" values.
  The lower value ran the risk of regenerating from slaves and ending
  up with *older* data than what was there.
* Avoid cache set() calls in replace() unless the lock was acquired.
  Use delete() instead in that case, which invalidates the cache.
* Remember if the cache is volatile in process memory instead of doing
  check key lookups for each "big" message to determine this. Use the
  message hash in the big message keys so purges to the former chain
  down to the latter. An "EXCESSIVE" key/revision map is now used in
  the main cache for big messages. This means that editing an existing
  big message will result in a different hash value. This is needed so
  purges propage correctly.
* Add logging when replace() fails to acquire the lock.
* Factored message cache update code duplication into a new method.
* Use makeKey() in more places, replacing deprecated wfMemcKey().

Change-Id: I82c5baa8137d1ffaaec6adace82ccb0181441342
2016-12-02 02:23:11 +00:00
jenkins-bot
1a04abebcb Merge "Replace Linker::link() usage with LinkRenderer" 2016-12-01 20:24:51 +00:00
Haikal Izzuddin
2c657ec256 Replace Linker::link() usage with LinkRenderer
Bug: T149346
Change-Id: Ie384566617f18ad6c3bf836b39702365d59f714d
2016-12-01 12:04:38 -08:00
Andrew Green
279e898222 MessageCache: some inline comments
Change-Id: I42427eef73d86c1a2e99dfa22b5dae159542e243
2016-11-30 08:20:05 +00:00
Andrew Green
3a4105ba01 Revert "MessageCache invalidation improvements" (temporary)
This reverts commit 9339a08b72
(Change-Id: Idc337a787171949c4f70186b13d7b65304c9b57f).

This is a temporary revert to prevent the change's inclusion in
wmf/1.29.0-wmf.4. That branch is scheduled to be deployed to WMF wikis
during the first week of the WMF's 2016 year-end fundraiser. Since
CentralNotice relies on MessageCache to fetch fundraising banners,
it is preferable not to deploy changes of any significant complexity in
that system at this time.

The original change should be re-applied at a later date. Sincere
apologies to the change's authors! :)

Change-Id: I8330838bbe03ce6ed38fa2e755b44519211d9d43
2016-11-28 19:31:42 -06:00
Aaron Schulz
8ae2c96b14 Make cache object mandatory for MessageCache
The only caller is MessageCache::singleton().

Change-Id: Ifcf0d458b9c691d6dce90b56b2f0f7d35e6ddef3
2016-11-22 13:02:10 -08:00
Aaron Schulz
9339a08b72 MessageCache invalidation improvements
* Increase time range for getValidationHash() using "latest" values.
  The lower value ran the risk of regenerating from slaves and ending
  up with *older* data than what was there.
* Avoid cache set() calls in replace() unless the lock was acquired.
  Use delete() instead in that case, which invalidates the cache.
* Remember if the cache is volatile in process memory instead of doing
  check key lookups for each "big" message to determine this. Use the
  message hash in the big message keys so purges to the former chain
  down to the latter. An "EXCESSIVE" key/revision map is now used in
  the main cache for big messages. This means that editing an existing
  big message will result in a different hash value. This is needed so
  purges propage correctly.
* Add logging when replace() fails to acquire the lock.
* Factored message cache update code duplication into a new method.
* Use makeKey() in more places, replacing deprecated wfMemcKey().

Change-Id: Idc337a787171949c4f70186b13d7b65304c9b57f
2016-11-16 18:22:17 +00:00
jenkins-bot
69ae945e8d Merge "Update weblinks in comments from HTTP to HTTPS" 2016-11-08 21:32:00 +00:00
Fomafix
202f695f67 Update weblinks in comments from HTTP to HTTPS
Use HTTPS instead of HTTP where the HTTP link is a redirect to the HTTPS link.

Also update some defect links.

Change-Id: Ic3a5eac910d098ed5c2a21e9f47c9b6ee06b2643
2016-11-07 15:24:46 +01:00
umherirrender
34fe90ac52 Remove empty lines at end of functions
It looks like there is something missing after the last statement
Also remove some other empty lines at begin of functions, ifs or loops
while at these files

Change-Id: Ib00b5cfd31ca4dcd0c32ce33754d3c80bae70641
2016-11-05 11:55:10 +01:00
jenkins-bot
12fb71be54 Merge "MessageCache: Use checkKeys for large messages" 2016-10-19 04:37:13 +00:00
jenkins-bot
875ccb3625 Merge "Make MessageCache::load() require a language code" 2016-10-19 01:38:43 +00:00
Aaron Schulz
aac4b448cf Make MessageCache::load() require a language code
Also make it protected; no outside callers exist.

Change-Id: I9f35d05a5e031d1c536a44b19b108803db068677
2016-10-18 17:50:12 -07:00
Andrew Green
3816a80a2c MessageCache: Use checkKeys for large messages
Also make use of the cache set options and use
Revision::newKnownCurrent() to avoid excessive
revision table queries during miss periods.

Bug: T144952
Change-Id: Ic1c649478b0f87420052d8c99b2962920f8b5c96
2016-10-17 22:52:28 -07:00
Kunal Mehta
61adc1e146 Use namespaced ScopedCallback
The un-namespaced \ScopedCallback is deprecated.

Change-Id: Ie014d5a775ead66335a24acac9d339915884d1a4
2016-10-17 15:46:05 -07:00
Elliott Eggleston
aa5be0c1e0 Only set memcache hash when saving messages to memcache
Shouldn't need to change the memcache hash unless we're changing the
memcache value.

Bug: T144952
Change-Id: I8e5cc29bfa0372f0071914e534e0b80cc4d34286
2016-10-13 12:57:32 -05:00
jenkins-bot
7e06100205 Merge "Clean up some ObjectCache factory callers" 2016-10-04 21:48:16 +00:00
Florian Schmidt
2d52e36018 Don't use Config as an access method for global objects
The Config interface (and it's implementation(s)) was never thought
to be an access method for objects saved in the global state, even
if it works with the current implementation GlobalVarConfig.

Imagine, that MediaWiki core switches to another file-based configuratiion
storage or a a database based one, we wouldn't be able to provide
access to global objects anymore, without weird hacks in the new
config-backend implementation or serializing objects to store in
the database or something else. This all isn't the idea with the Config
interface, as far as I know, so don't use it at all.

This commit changes the access to wgContLang to use the global keyword,
instead of accessing it through Config.

Follow up: Ice4f40911c3761c2542430935bc1898bc4e7a4d4
Follow up: I46f376a82205a5c99b98c9e971f9e9d7868ce9fb

Change-Id: I7a08b3bb649898abd445317a523051b07420b211
2016-10-04 17:40:35 +02:00
Aaron Schulz
88aa91f84a Clean up some ObjectCache factory callers
* Use services container in more places.
* Undeprecated getLocalServerInstance() since $fallback is not
  handled elsewhere.

Change-Id: Id1fcd1c465d2d92653357523f4225f1c4d1ace2f
2016-10-03 11:44:55 -07:00
Aaron Schulz
dac2faee5c Restore Content-Language header change from e53ff931a
This was lost in a rebase at some point.

Change-Id: I46f376a82205a5c99b98c9e971f9e9d7868ce9fb
2016-10-03 17:56:45 +00:00
Aaron Schulz
30f4b3c103 Replace DatabaseBase => Database in more places
Change-Id: If37a7909056bf2c31a8228cbc84f0fbbf5f1c517
2016-09-28 15:53:02 -07:00