Commit graph

107 commits

Author SHA1 Message Date
James D. Forrester
960e4d09ca Documentation: Replace misuse of 'later' when we meant 'latter'
Change-Id: I01bfdb8e0bfaa132533732873f7c840cea7935eb
2016-09-07 13:13:42 -07:00
Aaron Schulz
2e8d14593a Style and IDEA warning cleanups
* Avoid deprecated method use in MediaWiki.php.
* Move LBFactory::beginMasterChanges down a bit, next
  to LBFactory::commitMasterChanges.
* Rename $factory => $lbFactory.
* Remove redundant $conn->trxLevel() check.

Change-Id: I309ff3b8e3f586f0ac40b2f3be26b161993b58d2
2016-09-07 08:41:26 -07:00
jenkins-bot
9509503f51 Merge "Change "slave" => "replica DB" in /includes" 2016-09-05 23:47:08 +00:00
Aaron Schulz
16266edff3 Change "slave" => "replica DB" in /includes
Change-Id: Icb716219c9335ff8fa447b1733d04b71d9712bf9
2016-09-05 21:01:01 +00:00
Aaron Schulz
2fdf48c59c Renamed load balancer replica DB functions for consistency
Change-Id: Iec51366d383822d2afbd3fae285e251b78b0cdc7
2016-09-05 12:42:17 -07:00
Aaron Schulz
1cce2f77cd Always fail over to sync jobs when Special:RunJobs fails
This makes sure that jobs run one way or another.

Also made a few cleanups and improved the logging.

Change-Id: Ic2916099181ebeb5ae5143d444515db9ed13cee9
2016-08-31 05:24:02 -07:00
jenkins-bot
3d3118d807 Merge "Include PRESEND updates in ChronologyProtector positions" 2016-08-30 01:31:47 +00:00
Aaron Schulz
20400cb21f Move HTTP 304 check from performRequest to ViewAction
* Follow-up to 8b141886ed
* The method is now called after the setCdnMaxage() call
  in performAction.
* Allow any CDN urls for the title now, check $wgDebugToolbar,
  and allows caching redirects. The multi-step redirect case does
  not cache however, for simplicity.
* Removed now-unused code in Article that calculated $timestamp.

Change-Id: Ic4f4e3a79d7d386c2f15ca5b11dddf5c57ff9e9f
2016-08-29 14:23:16 -07:00
Aaron Schulz
2991f01032 Include PRESEND updates in ChronologyProtector positions
This updates are PRESEND for reason, so users should see them
on the next page view. Otherwise, they would be POSTSEND.

Change-Id: I533de550f6dd3e4b75507c2d25b1a05f7ac1301d
2016-08-28 17:01:55 -07:00
Aaron Schulz
8b141886ed Move Article checkLastModified() up to MediaWiki::performRequest
This lets revalidations via IMS headers run a bit faster.

Change-Id: I1f61086dea4c6bc460f6249ed7fda78316117a8d
2016-08-23 23:53:31 -07:00
Aaron Schulz
6a9e507dc5 Reduce problems caused by $wgRunJobsAsync
* Use getCanonicalURL() to avoid links with the wrong host (e.g.
  when it is virtual) and to avoid getting redirects.
* Also disable this setting when post-send execution is already
  available, by default.
* Bump the socket timeout slightly.

Bug: T107290
Bug: T68485
Change-Id: I56c43193fa6583cc0c8209ff59cf20c986a799a3
2016-08-22 23:26:50 -07:00
Aaron Schulz
bf5b5d7664 Use MediaWikiServices in restInPeace() for load balancer factory
Change-Id: Icc12100bd3409900c848c72a31417a8c25ae1021
2016-08-08 14:55:56 -07:00
Aaron Schulz
8b9aac2494 Add "PostSend" limits to $wgTrxProfilerLimits
This makes post-send updates subject to logging, like other
updates in POST requests. Previously, slow queries were ignored.

Bug: T137326
Change-Id: Ia08f51a10b7b1fae3350f5c5215fab234edefada
2016-06-08 10:47:53 -07:00
jenkins-bot
2b61c4181d Merge "Do not redirect to HTTPS when it's not supported" 2016-05-31 17:39:48 +00:00
Gergő Tisza
69f52123bb Do not redirect to HTTPS when it's not supported
Most URL generation happens via wfExpandUrl, which honors $wgServer
(or whatever setting it is told to use): if it has an explicit
protcol, that is always used; if it is a protocol-relative URL,
the protocol is selected based on the parameters given to wfExpandUrl.

One exception is MediaWiki::main() which always uses HTTPS if the
relevant cookie or user option is set, even if the wiki does not
support it. That can lead to annoying problems on Vagrant where it
is not unusual to turn HTTPS support on and off: when that happens,
the user can get locked out of the account.

Change-Id: I06982a26cd808f2aaa26753cd3353ed82473d9e0
2016-05-31 16:35:40 +00:00
Aaron Schulz
7f8d016f5a Avoid DBPerformance warnings on PURGE/TRACE requests
The former sometimes show up in the logs as they were causing
CentralAuth to use the master but the expectations treated
the request as a GET request. This makes things more
consistent.

Bug: T92357
Change-Id: I55bf3139c68f5926fe67a51cf0eb1b2ffe55d17b
2016-05-25 18:22:26 -07:00
Aaron Schulz
549af8bf91 Add WebRequest methods for determining "safe" requests
* This is useful for logic that decides what DB (master/slave) to use
  based on the nature of the web request. It could also be used to
  enforce clear read/write distinctions via exceptions if DB_MASTER
  is misused.
* Also fixed two IDEA errors while editing this class.

Bug: T134608
Change-Id: I43f4bc06c19d823d7d1ffd9cee8bbe60563c7f82
2016-05-10 11:17:28 -07:00
Aaron Schulz
2cafd151de Make MessageCache handle lock timeouts better
* Timeouts happen when memcached is cleared or on DC-switchover likewise
* Disable the sidebar cache when the MessageCache is disabled
* Also lower any output expiry for CDN and set a custom header
  when the MessageCache is disabled
* Log when this happens to a dedicated "MessageCacheError" channel

Bug: T133069
Bug: T7092
Change-Id: I1b80e250532033c52680246279e1e8f56350ae83
2016-04-21 13:18:29 +00:00
jenkins-bot
b8fce54279 Merge "Handle HTTPS when running jobs asynchronously" 2016-03-19 16:27:43 +00:00
Reedy
b5656b6953 Many more function case mismatches
Change-Id: I5d3a5eb8adea1ecbf136415bb9fd7a162633ccca
2016-03-19 00:20:58 +00:00
Cindy Cicalese
a65bef626b Handle HTTPS when running jobs asynchronously
Bug: T107290
Change-Id: Ie9af0e38c44c4097f25e701fc6a9a47a00f25d88
2016-03-14 12:08:09 -04: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
jenkins-bot
4b63ca7113 Merge "Set context on RedirectSpecialPage in MediaWiki.php" 2016-02-11 04:15:14 +00:00
umherirrender
4f2fe64283 Set context on RedirectSpecialPage in MediaWiki.php
Special page instance from SpecialPageFactory::getPage needs a context
set, to avoid using RequestContext::getMain in SpecialPage::getContext

Change-Id: I6e0828c6c9668c4ef10a729533190a5225b8782f
2016-02-04 20:14:03 +01:00
Brad Jorsch
2257fe4228 Revert "Remove SessionManager, temporarily"
This reverts commit 823db5d63dd5200d04c63da50ba6bf16f928e70b.

Change-Id: Ibb3e023e4eb6715295586dea87d0725c344a8271
2016-02-03 21:44:59 +00: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
Aaron Schulz
cca0a7e135 Move MaxUserDBWriteDuration logic to LBFactory
Change-Id: If7231af24f10ae29b7137f147abb60a351c9127f
2016-01-28 17:31:27 -08:00
Aaron Schulz
c4c81ee5a4 Cleanups and IDEA error fixes to initializeArticle()
Avoid using magic Article methods (use WikiPage instead).

Change-Id: I4057f78f3cde2185a6301a3444367196641a8e26
2016-01-20 00:16:59 +00:00
Aaron Schulz
bab8764cb7 Add more preOutputCommit() comments
Change-Id: Ia0b4c37b391b8e5e77397d21458f9638b49ebf71
2016-01-17 22:21:26 +00:00
Aaron Schulz
543b063773 Distinguish read vs write mode Action classes
Bug: T123589
Change-Id: I3c8fab646d3bb8cd468e5b60c27f3c5d43f9f97c
2016-01-15 01:13:38 +00:00
jenkins-bot
052770c40b Merge "Use dedicated cookie for skipping CDN cache after initiating DB changes" 2016-01-13 03:16:40 +00:00
Brad Jorsch
a73c5b7395 Add SessionManager
SessionManager is a general-purpose session management framework, rather
than the cookie-based sessions that PHP wants to provide us.

While fallback is provided for using $_SESSION and other PHP session
management functions, they should be avoided in favor of using
SessionManager directly.

For proof-of-concept extensions, see OAuth change Ib40b221 and
CentralAuth change I27ccabdb.

Bug: T111296
Change-Id: Ic1ffea74f3ccc8f93c8a23b795ecab6f06abca72
2016-01-12 21:57:01 +00:00
Aaron Schulz
5e0162f919 Use dedicated cookie for skipping CDN cache after initiating DB changes
This sets a short lived cookie that more robustly takes on the role that the
session initiation in SubmitAction has. It can be used via Varnish VCL.

Bug: T121440
Change-Id: I6214a0bce4e8bbbecbc3f9513e7c852285b4a9db
2015-12-23 12:50:59 -08:00
Aaron Schulz
58cffd04b8 Pass __METHOD__ to load balancer commit/rollback methods
Change-Id: I3fd87908c2a493fae49de6a29efe79f8d433c112
2015-12-22 18:30:20 -08:00
Amir E. Aharoni
a94900fab0 Fix transaction-duration-limit-exceeded
* Fix the wording.
* Add PLURAL support.

Bug: T121821
Change-Id: I9cf27534a5b7a055a7c2544f6366dd0e40c5e9a3
2015-12-19 23:23:18 +02:00
Bartosz Dziewoński
7972a4e811 Add $query to JavaScript redirect info
Bug: T109724
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Change-Id: I57a8f75067365d3da6388d2f8f7fe95ed5e6f310
2015-12-18 01:46:04 -08:00
csteipp
1461ff2ecf SECURITY: Make Special:MyPage and friends fake redirect to prevent info leak
This prevents a malicious person from using external resources on their
website to cause the victim's web browser to load
Special:MyPage -> User:Username, and then looking it up in the page hit
statistics in order to correlate IPs from the malicious person's server
log, with usernames on wiki.

This feature can be disabled with $wgHideIdentifiableRedirects.

Bug: T109724
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Change-Id: Ia0e742dc92c77af4832174dfa24c6dcaa6ee80e9
2015-12-18 01:46:03 -08:00
Aaron Schulz
ec12adf649 Expand MediaWiki::main() $wgTrxProfilerLimits logging
Remove the filter for basic GET actions.

Change-Id: Iba2b233474321f3d097bf9dfcf90b0feec0312b6
2015-12-16 15:19:29 -08:00
Aaron Schulz
4302b0419d Rename getSquidURLs() => getCdnUrls()
Change-Id: I433acc7990a5fcefd0d2ff5b14ba33dec0424706
2015-12-11 16:40:35 -08:00
Aaron Schulz
6af3c39c07 Replace "squid" with "CDN" in various comments
Change-Id: Idcc528daf28e119349155d36e30a9bcf61b2e7d5
2015-12-09 17:35:37 -08:00
Aaron Schulz
f606fd8d5c Rename setSquidMaxage() => setCdnMaxage()
Also updated the OutputPage member variable.

Change-Id: I0b41c66da58c6126c1bd96170c02d084a067383c
2015-12-09 17:11:23 -08:00
Aaron Schulz
c30b049580 Add $wgMaxUserDBWriteDuration to limit user-generated transactions
This is a low level catch-all net for huge updates that still slip
through. Features that let users add/remove arbitrarily many rows
to lists of arbitrary size can easily result in high lag due to
strange usage patterns or deliberate attacks.

Also removed duplicate 'autochange-username' JSON key.

Bug: T95501
Change-Id: I58a91ca23cae528ef1954d2d78c8f0a90681983e
2015-12-04 13:08:52 -08:00
Aaron Schulz
34dd248e28 Add pre-send update support to DeferredUpdates
* PRESEND/POSTSEND constants can now be used in addUpdate()
  and addCallableUpdate() to control when the update runs.
  This is useful for updates that may report errors the client
  should see or to just get a head start on queued or pubsub
  based updates like CDN purges. The OutputPage::output() method
  can easily take a few 100ms.
* Removed some argument b/c code from doUpdates().
* Also moved DeferrableUpdate to a separate file.

Change-Id: I9831fe890f9f68f9ad8c4f4bba6921a8f29ba666
2015-12-04 19:08:27 +00:00
jenkins-bot
18ec10a358 Merge "API DB commit and sticky DC cookie fixes" 2015-11-23 00:43:59 +00:00
Aaron Schulz
85edec239e API DB commit and sticky DC cookie fixes
* Make sure the API commits DBs *before* sending the
  response, in case something goes south which would
  make a sent response wrong.
* Make sticky DC cookies trigger with api.php too.
* Make sure UseDC cookies do not end up with a prefix.
  VCL rules should not have to deal with having a DB
  name as a prefix or such. This was an oversight.

Change-Id: I9e4090ab15c1c1493b0589a710184745dac9b0c1
2015-11-19 12:33:28 -08:00
Aaron Schulz
85c0f85e92 Decouple ChronologyProtector from user sessions
* It now works for users without using sessions.
  Sessions should not be cluttered with things
  unrelated to authentication and tokens.
* Public services doing api.php requests on behalf
  of a users only need to set XFF headers (as normal)
  for position wait logic to trigger. They can opt out
  of ChronologyProtector via a new HTTP header
  "ChronologyProtection: false".
* Requests across subdomains, such as the SUL2 handshake
  for CentralAuth on account creation, now have position
  wait logic applied. This helps avoid anomolies were a
  row just written in the last request may not be seen.
* Use merge() to avoid rolling back master positions if
  the user has multiple tabs open and doing writes at once.
* $_SESSION global state is gone from ChronologyProtector.
* Cleaned up post-send LBFactory::shutdown() logic for
  avoiding master position writes with an explicit flag.
* Use 'replication' debug log group in more places.

Bug: T111264
Change-Id: Ib25d05994d62b25c2f89e67b7f51009c54f4bca8
2015-11-12 23:11:18 +00:00
Ori Livneh
8340400f27 Add Timing interface
* Add `Timing`, an interface which mimics the W3C User Timing API.
  It provides a canonical way to store and retrieve markers (timestamps)
  and measures (timestamps + duration).
* As the initial use-case, use it to record 'requestShutdown'.

Change-Id: I36b29162ffcc091406df025463b0e2797e52f19a
2015-11-03 15:05:37 -08:00
Aaron Schulz
a8590172c8 Make DeferredUpdates::doUpdates always commit per task
* All callers are either using commit already or would be fine
  using it (e.g. Maintenance scripts and JobRunner that have
  no real transaction open).

Change-Id: I9f54b27619da6dac2cb63d255995aabc4ee78002
2015-10-22 01:27:08 +00:00
Aaron Schulz
0477d11be6 Send X-Database-Lagged header to help with debugging
Change-Id: Ib654c49a61a1279091c5da92a2bef2ad1f992d23
2015-10-21 18:58:02 +00:00
umherirrender
977c810302 Remove empty line comments
Remove empty line comments as found by the
MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.EmptyComment sniff

Change-Id: I5d694f7a7d3bc97e16300ba03c60ad17f3c912a5
2015-10-14 09:46:44 +02:00