Commit graph

177 commits

Author SHA1 Message Date
jenkins-bot
c1bfb7d319 Merge "Rename CDN config variables to be generic, deprecating the old names" 2019-05-24 21:39:53 +00:00
James D. Forrester
f9f8dff40f Rename CDN config variables to be generic, deprecating the old names
Hook, methods, classes still to rename where appropriate.

Bug: T104148
Depends-On: Id34339dff88bc6d1863378ac94b96b2d590b891d
Depends-On: I4e2938395bcbf7956b83fff00978f09c61dcfa36
Change-Id: I7a725dae551c867a4fa7c213838d52c7fb862756
2019-05-24 21:09:22 +00:00
Aaron Schulz
314809d35c Make MediaWiki::preOutputCommit() handle PRESEND deferred updates with the "run" parameter
This means that enqueuable updates (LinksUpdate, LinksDeletionUpdate) will run immediately
at this point rather than be enqueued as jobs. This only affects ApiPurge since the other
callers use either POSTSEND or "false".

Change-Id: I8b6ff6c9a68730374e6d83682e774e4f4bfbf52f
2019-05-24 14:05:15 -07:00
Timo Tijhof
7ac7ffc2b3 specials: Add $subpage param to RedirectSpecialPage::getRedirectQuery
This will make it easier to create redirects where $subpage is the title,
e.g. "Special:Example/Foo?x=y" to "index.php?title=Foo&x=y".

To do that conveniently, getRedirectQuery() needs access to $subpage.
The alternative is to do Title-parsing inside getRedirect(), which then
complicates this significantly as one has to deal with absence of a title
(null) and invalid titles (illegal chars etc.).

By using it plainly as query parameter (defaulting to null/omitted), this
is all deferred to index.php, which seems like a better separation of
concerns.

Motivated by SpecialMobileHistory in MobileFrontend (Ic0aea7ee340a).

Change-Id: I9fe78f479053fb55952ba78850d2fc281a039fe3
2019-04-15 14:44:38 +00:00
Thiemo Kreuz
31aeedb98a Add some more missing limit parameters to explode() calls
I benchmarked this again. The runtime of an unlimited explode() can be
quite high. This is not really a DoS attack vector as it would require to
post megabytes worth of input to the code, which will hit many other
limits before. I still consider it good practice to use unlimited explode()
only when it is actually allowed to return an unlimited amount of elements.

Change-Id: I30f8ca5dba7b317bb4a046b9740fd736b4eea291
2019-04-05 14:34:39 +00:00
Reedy
c13fee87d4 Collapse some nested if statements
Change-Id: I9a97325d738d09370d29d35d5254bc0dadc57ff4
2019-04-04 19:02:22 +00:00
Thiemo Kreuz
a2c1d8c043 Use the WebRequest::getCheck() shortcut where possible
This is inspired by Ib117e05.

As far as I can tell this is functionally identical. Even arrays should
behave the same, as both the getVal() and getCheck() methods do have a
special case that returns the `null` default in case the user tried to
pass multiple values instead of a single scalar.

Change-Id: Id4e4ec91f39d3c39461bd41673bdafc3bde11737
2019-03-11 09:50:52 +01:00
Aaron Schulz
276d065d16 Persist sessions pre-send instead of post-send
This avoids race conditions with certain web request patterns

Bug: T214471
Change-Id: I4dfee10326485e98b028585c7da2e6b30787bb91
2019-02-06 14:28:02 -08:00
Aaron Schulz
b1b67c9ac6 Add TransactionProfiler::redefineExpectations and migrate appropriate callers
Some of the callers of setExpectations() actually need to reset the old
expectations to avoid erroneous warnings.

Change-Id: I63c01c0f6cd748bdc849f1a5264e17bd377b9d11
2018-12-10 16:02:30 +00:00
jenkins-bot
c6ad2554f4 Merge "Add isCurrentWikiId()/isCurrentWikiDomain()/getCurrentWikiDomain() to WikiMap" 2018-10-29 22:27:15 +00:00
Aaron Schulz
dcd0a3d534 Add isCurrentWikiId()/isCurrentWikiDomain()/getCurrentWikiDomain() to WikiMap
Use these in place of various wfWikiID() calls.

Also cleanup UserRightsProxy wiki ID variable names and removed unused
and poorly named getDBname() method.

Change-Id: Ib28889663989382d845511f8d34712b08317f60e
2018-10-29 14:53:37 -07:00
jenkins-bot
dea8f5344b Merge "Create JobQueueEnqueueUpdate class to call JobQueueGroup::pushLazyJobs()" 2018-10-28 23:10:53 +00:00
Aaron Schulz
6030e9cf2c Create JobQueueEnqueueUpdate class to call JobQueueGroup::pushLazyJobs()
This assures that MergeableUpdate tasks that lazy push job will actually
have those jobs run instead of being added after the lone callback update
to call JobQueueGroup::pushLazyJobs() already ran.

This also makes it more obvious that push will happen, since a mergeable
update is added each time lazyPush() is called and a job is buffered,
rather than rely on some magic callback enqueued into DeferredUpdates at
just the right point in multiple entry points.

Bug: T207809
Change-Id: I13382ef4a17a9ba0fd3f9964b8c62f564e47e42d
2018-10-28 22:19:06 +00:00
Aaron Schulz
0ee8b1652b Move timing code out of the try/catch in doPostOutputShutdown()
Change-Id: Idc24fdaff5bbcb98445cc4dee8c94cc75cd00573
2018-10-25 09:22:30 -07:00
Alangi Derick
b4ecf374fe Fix PHPDoc type for instance variables and methods
Should be "string" not "String" and "array" not "Array" in
@param, @return and @var use cases. Also, minor typo fixes.

Change-Id: I9d5ebc5b741c6560907b95f7c0c4039da2861f4a
2018-10-21 13:00:25 +01:00
James D. Forrester
162af29e77 Drop UnknownAction, deprecated in 1.19(!)
Change-Id: Ia75552e69c07f6dc5da2f1e04ea813c912b04aef
2018-10-10 16:17:28 -07:00
Krinkle
1c101265cf Revert "Replace Media namespace redirects with File namespace"
Per T203942.

This reverts commit 613e269920.

Change-Id: I4febbe9c650894976a580e584d0a7c11de12ff37
2018-10-09 01:19:12 +00:00
Alex Ezell
613e269920 Replace Media namespace redirects with File namespace
If a user creates a redirect that goes to a [[Media:example.jpg]]
page, then an exception is thrown because NS_MEDIA is a virtual
namespace. This change catches this case and changes the namespace
to an NS_FILE namespace and the redirect works correctly. This
change only happens when we are dealing with a redirect so other
uses of the NS_MEDIA namespace shouldn't be affected.

Bug: T203942
Change-Id: Ia744059650e16510732a65d51b138b11cbd43eb4
2018-10-05 18:04:24 -04:00
Aryeh Gregor
e68fdb4065 Mass conversion to SpecialPageFactory service
Change-Id: Ia6e1e819ec6cbe8bf75b820109f51d47863e31fc
2018-08-17 12:03:12 -07:00
petarpetkovic
b7a4e82545 Fix some of the common typos
* supress -> suppress (Except in backup_LogTest.php)
* recomend -> recommend
* becuase -> because
* accross -> across

Bug: T201491
Change-Id: I8faa4e6cc688b3ee204b3f79ab55eb7b65cc1fdd
2018-08-16 00:59:32 +02:00
Aryeh Gregor
90d4f56fe4 Mass conversion of $wgContLang to service
Brought to you by vim macros.

Bug: T200246
Change-Id: I79e919f4553e3bd3eb714073fed7a43051b4fb2a
2018-08-11 22:44:29 -06:00
Fomafix
88f469624d Use $lang->hasVariants() instead of count( $lang->getVariants() ) > 1
Change-Id: I23668c69a8d8cc886168cbbd4f94cf13b597b5a6
2018-07-11 16:13:17 +00:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
jenkins-bot
eb0758923d Merge "Disable WebResponse setters for post-send processing" 2018-06-13 13:21:51 +00:00
Brad Jorsch
23706be35c Disable WebResponse setters for post-send processing
When jobs are being run synchronously post-send, we don't want to allow
bugs to result in a job somehow setting cookies or headers that
interfere with those that were intended to be set in the request.

Bug: T191537
Change-Id: Ib5714a17af417797140f99e41eaacbba1bfd20f4
2018-06-12 12:35:41 -04:00
Fomafix
e1630b6a53 PHP: Use short ternary operator (?:) where possible
Change-Id: Idcc7e4fcdd4d8302ceda44bf6d294fa8c2219381
2018-06-11 11:26:35 +02:00
Aaron Schulz
fb51330084 rdbms: include client ID hash in ChronologyProtector cookies
Previously, if an internal service forwarded the cookies for a
user (e.g. for permissions) but not the User-Agent header or not
the IP address (e.g. XFF), ChronologyProtector could timeout
waiting for a matching writeIndex to appear for the wrong key.

The cookie now tethers the client to the key that holds the
DB positions from their last state-changing request.

Bug: T194403
Bug: T190082
Change-Id: I84f2cbea82532d911cdfed14644008894498813a
2018-06-02 03:57:30 +00:00
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
Aaron Schulz
52af356cad Avoid unnecessary WaitConditionLoop delays in ChronologyProtector
Since it takes time for the agent to get the response and set the
cookie and, as well, the time into a request that a LoadBalancer is
initialized varies by many seconds (cookies loaded from the start),
give the cookie a much lower TTL than the DB positions in the stash.

This avoids having to wait for a position with a given cpPosIndex
value, when the position already expired from the store, which is
a waste of time.

Also include the timestamp in "cpPosIndex" cookies to implement
logical expiration in case clients do not expire them correctly.

Bug: T194403
Bug: T190082
Change-Id: I97d8f108dec59c5ccead66432a097cda8ef4a178
2018-05-18 13:43:05 -07:00
Aaron Schulz
123924440e Silence TransactionProfiler in MediaWiki::triggerSyncJobs
Change-Id: Id04e7d25cbf7a4d05dfd80c7a32965312978ef39
2018-05-02 12:01:40 -07:00
James D. Forrester
bf61efd874 Deprecate $wgUseAjax, act as always-true
Change-Id: Ia224c7ea1f902714e2c11bdebb9dadcd1ddfe43f
2018-04-18 00:50:45 +00:00
Aaron Schulz
8aeedcbabd Cleanup some comments related to DB replication
Change-Id: Icaaa5144beaedfebb88530480733a1e916c935fb
2018-03-09 23:05:43 +00:00
Reedy
39f0f919c5 Update suppressWarning()/restoreWarning() calls
Bug: T182273
Change-Id: I9e1b628fe5949ca54258424c2e45b2fb6d491d0f
2018-02-10 08:50:12 +00:00
Aaron Schulz
12d380b37e Catch Error exceptions in MediaWiki::run()
This avoids triggering other exceptions down the road such as
"Got COMMIT while atomic sections FileDeleteForm::doDelete,
LocalFile::lockingTransaction are still open". Those would
happen in LBFactory::__destruct(), when it tries to commit any
dangling transactions (firing attached callbacks too). Just like
with the Exception case, the DBs needs to all be rolled back.

Also make LoadBalancer::rolbackMasterChanges() rollback any
explicit transactions even if they have no pending changes.
This clears up the state to avoid later atomic section errors.

Change-Id: Ic0b6b12c1edc1eec239f4f048359b3bbb497d3ff
2018-02-09 11:14:11 -08:00
jenkins-bot
92f9cb0551 Merge "Replace cpPosTime cookie/parameter with cpPosIndex" 2018-01-12 18:09:00 +00:00
jenkins-bot
3b7f453963 Merge "Add some @noinspection flags to doPostOutputShutdown()" 2018-01-04 19:45:52 +00:00
Aaron Schulz
d5aa846d84 Replace cpPosTime cookie/parameter with cpPosIndex
This handles multi-DB transactions properly, instead of causing wait
timeouts in the WaitConditionLoop. It also is more correct in using
a counter instead of relying on wall clocks.

In addition:
* Refactor related code in MediaWiki.php to be comprehensible.
* Always send the cookie even the "remote wiki redirect" case.
* Renamed ChronologyProtector field and constant to avoid any
  confusion of "wait for server X to reach Y" with "wait for Y
  to show up in position store".
* Add an "asOfTime" field to the position keys for debugging.

Bug: T182322
Change-Id: I5c73cd07eaf664f02ba00c38fab9f49b609f4284
2018-01-02 17:00:32 -08:00
Aaron Schulz
336454104d Try to opportunistically flush statsd data in maintenance scripts
This helps to avoid OOMs from buffer build-ups in the statsd
factory object. This piggy-backs on to the same checks used
for deferred update runs. In addition, the output() method
checks if the data size is getting large and emits if needed.

Bug: T181385
Change-Id: I598be98a5770f8358975815e51380c4b8f63a79e
2017-12-30 05:01:21 +00:00
Aaron Schulz
c2d3e79e35 Add some @noinspection flags to doPostOutputShutdown()
This are in "use" clause of $callback, by reference

Change-Id: Iadb1d25263dbafe2bd12223db62e1c93e2188bde
2017-12-02 12:38:58 -08:00
James D. Forrester
88ba64343b OutputPage: Hard-deprecate setSquidMaxage, renamed since 1.27
Renamed and deprecated in MediaWiki in f606fd8d since 1.27.

Only six uses in Wikimedia-hosted git repositories, marked as
dependencies. Also one use snuck back into MediaWiki itself,
fixed in this patch.

Depends-On: Ie8c13a6b1dc1b7861f6c27bbba996099375f066b
Depends-On: Ic2ea90343efda6533c06ca1325bc85d9aa776078
Depends-On: Ibba2f486f0ecb684ded7efb09f9942f5e0f5fd7a
Depends-On: Id27a48e10fd127e00f68e1020e8f40e30ba9a251
Depends-On: Ifd6db7910a71bb700484d6b588327424f11c00e0
Depends-On: I6523059941eb5f86274e364a8d5cc74b849655a4
Change-Id: I2cdfcd60fc7934830e3e6ec132958aa2aa1fe486
2017-11-02 11:51:58 -07:00
Aaron Schulz
aafaea29f3 Distinguish GET from POST for PostSend expectations
This avoids needless log entries for POST requests.

Bug: T166199
Change-Id: I515fde1f619f7f016d08b7c270a1c155ee171bf9
2017-09-28 12:05:03 +02:00
Aaron Schulz
9ae936b197 Prefer that enqueueable post-send updates are run immediately
If the user is not waiting at this point, so there is not much
reason to enqueue a job over just doing the work now. Running
the update now gives more immediate results however.

This has the effect of  making LinksUpdate run post-send for
forward link updates, since the addUpdate() call in WikiPage uses
the default POSTSEND mode. These updates used to be synchronous
in the past, before proper post-send update support. With post-send
updates, there is not much benefit to using the job queue here.

If post-send updates are not supported, this will continue to
use the job queue.

If a caller needs such updates to enqueue post-send to avoid DB
updates on HTTP GET or if the update is too big to run outside of
JobRunner, it can always just use JobQueueGroup::lazyPush() with
a direct job object or JobSpecification.

Change-Id: Ibc4b1e17538cc8b1fba7d13759e1ebb83abed869
2017-09-14 10:21:16 +02:00
Aaron Schulz
15cb57b3b5 Avoid preemptive DB replication waits for farm cross-wiki redirects
This previously only worked if $wgLocalVirtualHosts was set, which
was too specific to check and not used by WMF. Use the more generic
WikiMap class.

Two methods have been added there to do the work of enumerating
canonical wiki farm URLs and checking them against a given URL.

Bug: T172357
Change-Id: Id2415bab5d7f5a08b9f536858c32d329138384a2
2017-08-23 15:37:35 -07:00
Umherirrender
3f1a52805e Use short type bool/int in param documentation
Enable the phpcs sniffs for this and used phpcbf

Change-Id: Iaa36687154ddd2bf663b9dd519f5c99409d37925
2017-08-20 13:20:59 +02:00
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