Commit graph

133 commits

Author SHA1 Message Date
Aaron Schulz
6b982c7978 Check headers_sent() before sending cpPosTime headers
Some entry points stream output and flush their own headers.
This avoids "headers already send" warnings in some cases.

Change-Id: Ifb232d4575486749bbbccba88f3f688972fe9c20
2017-07-22 00:21:42 -07:00
Umherirrender
b5cddfb27b Remove empty lines at begin of function, if, foreach, switch
Organize phpcs.xml a bit

Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
2017-07-01 11:34:16 +00:00
Aaron Schulz
8fc7ebaaa2 Push lazy jobs when exceptions are handled by MWExceptionHandler
Remove the exit(1), which does not seem to be needed by any callers.
Doing so means that post-send updates can still happen, such as the
pushing of lazy jobs.

Better avoid showing exceptions in doPostOutputShutdown(), given
that an error may have already been shown. By the post-send part,
it's to late to show errors anyway.

Bug: T100085
Change-Id: Ib1c75323f222a0e02603d6415626a4b233e8e1c7
2017-07-01 00:03:11 +00:00
Timo Tijhof
41f4a25131 filecache: Use current action instead of "view" only in outage mode
Regression from 3ad9e41be9. Prior, $action was also passed to HTMLFileCache.

Change-Id: Ie0f1c8b73d306bc710c346ad97868c53fb59809d
2017-06-27 20:56:59 -07:00
Aaron Schulz
95fdff36c2 Make DeferredUpdates detect LBFactory transaction rounds
Previously, tryOpportunisticExecute() tried to nest transaction rounds,
which would fail. Added LBFactory::hasTransactionRound() as needed.

Also cleaned up some unqualified class names in callbacks and set the
PRESEND flag for the JobQueueDB AutoCommitUpdate callback. Use the
proper getMasterDB() method while at it. These follow up 24842cfac.

Bug: T154425
Change-Id: Ib1d38f68bd217903d1a7d46fb15b7d7d9620daa6
2017-06-10 15:22:32 +00:00
Seb35
24842cfac0 Use AutoCommitUpdate instead of Database->onTransactionIdle
This is needed for deferred updates LinksDeletionUpdate and LinksUpdate, else
callbacks registered with onTransactionIdle prevent other transactions from
being executed, at least in this case.

Bug: T154425
Bug: T154438
Bug: T157679
Change-Id: Iecd396d584a62ac936cd963915339159467b44cd
2017-06-06 14:23:37 +02:00
Seb35
d80fca05e1 Better handling of jobs execution in post-connection shutdown
In the postprocessing, some jobs can be executed but given the deferred
updates were already "closed", any new DeferredUpdate were directly called
(as explained by Krinkle on T165714), and the transactions opened by
classical jobs are badly mixed with transactions (directly) executed by
DeferredUpdates jobs, issuing a DBError, avoiding the job, which stays
in a 'claimed' status even if failed.

Quite similarly, some DeferredUpdates callables use JobQueueGroup::lazyPush
so it is needed to really push the generated jobs.

This change removes the run-immediately-deferred-updates behaviour even
in the post-connection shutdown, and given there is a call to
DeferredUpdates::doUpdates in JobRunner::execute it is not necessary to
add another one and hence execution of Web jobs is more similar to execution
of CLI jobs. In the same spirit to reconcile Web jobs and CLI jobs, the
call to JobQueueGroup::pushLazyJobs is done in JobRunner::execute.

Bug: T165714
Bug: T100085
Change-Id: I721e7167eca5b0b6227234fe516005243ab22388
2017-06-01 13:16:08 +02:00
Fomafix
5c41b29993 Use isSpecialPage() where possible
Change-Id: Ie4d0838acf96a7ed4a1fe4cfdc901c77d3312174
2017-04-29 22:31:42 +02:00
Aaron Schulz
dd359741cc Move DB errors to Rdbms namespace
Change-Id: I463bd86123501abc68fdb78b4cda6110f7af2549
2017-04-15 10:47:41 -07:00
Aaron Schulz
cb84ec7f4a Catch errors in more cases inside MediaWiki::triggerJobs()
This catches things like "DB is read-only" when doing pop()/ack() from the
job table with sqlite.

Also spun off some code to new trigger*Jobs() methods for readability.

Bug: T88312
Change-Id: I2a09248e40867684d48e6739da5e4a90581fa6ce
2017-03-27 14:10:22 -07: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
4a177b34ef Move LBFactory to Rdbms namespace
Change-Id: I5ae10783228d0252284807c9562bc8e328d4becb
2017-02-03 17:24:03 -08:00
Aaron Schulz
59053a0716 Move ChronologyProtector/TransactionProfiler to Rdbms namespace
Change-Id: I37a655bd8bd267c9bc32028b55925b2dce527d33
2017-01-26 10:30:57 -08:00
rlot
0eadfdeb17 Fully deprecate 'ContentAction' hook
Bug: T54027
Change-Id: Ia765e25a9f76b34f7b10125d3b6e0c8e00fac2ca
2017-01-02 18:35:06 +00:00
jenkins-bot
84851a43f3 Merge "Revert "MediaWiki.php: Redirect non-standard title urls to canonical"" 2016-11-09 01:27:38 +00:00
Aaron Schulz
7d4b206aa9 Improve getUrlDomainDistance() return values
This change is just cosmetic given the caller it has.

Change-Id: I591f92e56d9f5574d032dda380bc03b491b10738
2016-11-02 21:56:00 -07:00
Roan Kattouw
e98dc4f3c2 MediaWiki.php: Make getUrlDomainDistance() actually static
It's only called once, and that call is static. It also doesn't use $this.

[error] /w/index.php?title=New_new_page&action=purge
ErrorException from line 610 of /vagrant/mediawiki/includes/MediaWiki.php: PHP Strict Standards: Non-static method MediaWiki::getUrlDomainDistance() should not be called statically

Change-Id: Ice66937a32193720c52df39bcea90659a8d9f653
2016-10-14 21:17:43 +00:00
Aaron Schulz
4a2085523f Make SessionBackend::save() update the user post-send
Bug: T92357
Change-Id: Id4f4991aca1ceeb74b59e980f09863041246a4fc
2016-10-12 11:14:45 -07:00
Aaron Schulz
108ccb0352 Make rebuildFileCache cover ?action=history
Also simplified the logic slightly

Change-Id: I6145d52b6b701735fa4bd8e41e07fb2bf6fdcee3
2016-09-20 00:53:26 -07:00
Aaron Schulz
3ad9e41be9 Fix $wgFileCache DB outage fallback
Change-Id: I5c41b4669ca29d119de5c08a2c61dbadae7cf55c
2016-09-16 02:18:12 +00:00
Aaron Schulz
16b4e3a9f1 Avoid global state in DatabaseBase::factory()/query()
Change-Id: Ibb4f1c0dafea071a1c34e0cd5b5c15b8b4bb7bc6
2016-09-16 00:40:57 +00:00
Aaron Schulz
a3814f52c4 Set cpPosTime cookie for the non-redirect case as well
This is useful if the ChronologyProtector store cannot sync
among datacenters and waitForReplication() is DC-local.
It only applies if the user stays on the domain, however.

Change-Id: I800cade7b87a0f02d6a429e70924c54189a4a7af
2016-09-13 23:52:11 -07:00
Aaron Schulz
c954a4efe8 Use cpPosTime cookie for same-domain redirects on DB change
This follows-up a3dacac90f to show the URL parameter in less cases.

Change-Id: Ibe015352962fb3ee14d5aa322f0e748ef4cba5c1
2016-09-14 05:56:25 +00:00
Chad Horohoe
3635881b44 Avoid warnings when unable to parse the URL given to us
Change-Id: I56f1f36a3a54c6c23579f011d65dc75f30cb6dcf
2016-09-13 14:07:32 -07:00
Aaron Schulz
a3dacac90f Support masking the WRITE_SYNC latency from ChronologyProtector
* Use OutputPage::output() as the method to mask latency, since it
  takes a good while to run. By the time it runs, cache replication
  should have caught up, so the reap call will likely not block.
* For redirects emitted after changes in POST, instead of masking
  with OutputPage, add a parameter to the redirect and block on
  the positions appearing. This uses the redirection RTT to mask
  the replication latency.

Change-Id: Ib23690c302e8033610fef9a0ef451dafe8a5803e
2016-09-12 23:58:49 +00:00
Paladox
799eb213d5 Revert "MediaWiki.php: Redirect non-standard title urls to canonical"
This reverts commit 155d555b83.

Bug: T106793
Change-Id: I3c29131ea2041fa7429eae5fab5fae04e39f3da0
2016-09-09 21:45:27 +00:00
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