Commit graph

11 commits

Author SHA1 Message Date
Chad Horohoe
fefc89448d MWException: Remove deprecated methods
No callers in core or extensions.

Change-Id: I3e2dc615bcd23838cf096625a767a7cf50fea140
2014-05-14 22:01:37 +00:00
Chad Horohoe
cfbeb437a3 MWException: Don't send headers multiple times
Ideally we wouldn't have sent headers yet, but in some weird
code paths where we output stuff raw (like Export) we might
have already sent them.

All depends on when the failure happened.

Should silence all of the "headers already sent" being seen
from exports.

Change-Id: I12e0532e93d30b2255f73a9d0e017c73e30c3e28
2014-05-13 14:40:39 -07:00
Siebrand Mazeland
f994817f6b Pass phpcs-strict on various files in includes/
These files have all had treatment before, and these occurrences have either
been missed or have been introduced after.

Change-Id: I06cdab4616b5bff47c85152df28f18c861730a23
2014-04-24 21:50:01 +02:00
umherirrender
9c614ac02d Fixed some @params documentation
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.

Change-Id: I8c9f30128b46086064326708a4878228ba459447
2014-04-14 19:52:18 +00:00
Timo Tijhof
03d4947289 MWException: Fix sitename appearing twice in <title>
The MWException::getPageTitle method is wrapping the page title
in the 'pagetitle' ($1 - sitename) message, but OutputPage does
this as well when outputing <title>.

OutputPage::prepareErrorPage takes the first parameter as page
title (unwrapped, appears in <h1>,) and the second optional one
is for <title>, which (if omitted, like before) results in
pagetitle being applied by OutputPage.

Now that we specify them separately, this also removes the
sitename from the <h1> on the page, which always looked weird.

It also fixes DBQueryError (extends MWException) where previously
no sitename was added, it just returns 'databaseerror' from
its DBQueryError::getPageTitle() method.

Change-Id: I85d65d89e72b4497a050f440524ff6f959518b88
2014-03-31 11:49:54 -07:00
jenkins-bot
57c4cd7ce5 Merge "Improve handling of uncommitted DB txns with "uncaught" exceptions" 2014-03-31 16:30:33 +00:00
Faidon Liambotis
acdfea8836 Set ThrottledError's response code to 429
ThrottledError currently returns a 503, which in turn results into
badly-written spambots occasionally flooding our 5xx logs and graphs.

There is no reason, however, for ThrottledError to return a 5xx in the
first place: it's a user-generated error (user hitting a rate limit and
being throttled), not a server error. 5xx error codes in general have
many other implications, such as frontend caches treating this as a
backend failure and potentially retrying the same request, so they are
unsuitable and undesirable for the ThrottledError exception.

RFC 6585 (April 2012, updates: 2616) has added a special 4xx code
specifically for rate-limiting, 429 Too Many Requests. As the
description of that code matches exactly what ThrottledError was meant
for, switch it to using 429 instead.

Note that there is a chance 429 might be mistreated and not showed by
older or badly-written user agents as it's fairly new and not part of
RFC 2616, the original HTTP/1.1 spec. However, the last paragraph of
section 6.1.1 of RFC 2616, specifically covers the issue of UAs &
unknown status codes: it dictates that applications MUST understand the
class of any status code and treat them as the "x00 status code of that
class" (here: 400), MUST NOT be cached, and "SHOULD present to the user
the entity returned with the response, since that entity is likely to
include human-readable information which will explain the unusual
status".

Change-Id: I46335a76096ec800ee8ce5471bacffd41d2dc4f6
2014-03-28 12:25:59 +02:00
Brad Jorsch
dc7d342d93 Improve handling of uncommitted DB txns with "uncaught" exceptions
One of the causes (if not the cause) of bug 56269 is if something
manages to throw an exception that makes it to MediaWiki::run's
last-resort exception catcher while having an open database transaction:
the transaction never gets committed or rolled back, so it gets
implicitly rolled back and a warning is raised.

The API has the opposite problem in bug 63145: it catches the exception
but then does the normal DB shutdown which *commits* the transaction.
This is certainly the Wrong Thing to do.

Ideally, neither of these would ever happen because any code using
transactions would have its own try-catch that would catch any
exception, rollback the transaction, and then rethrow the exception. But
it happens anyway, so let's have both of these last-resort exception
handlers do the rollback, and also log the exception so the throwing
code has a better chance of being properly fixed.

Bug: 56269
Bug: 63145
Change-Id: I8f1da51187b281fe4afc0d5a0c49f5caf3612e92
2014-03-27 12:46:07 -04:00
Brian Wolff
485ff9ead9 MWException: Expand {{SITENAME}} in pagetitle with Message::text()
Bug: 58447
Change-Id: I5f4fcb6d6e044f708cd6adb1bc7312d592fc74dd
2014-03-21 22:12:47 +00:00
addshore
7a56bf8168 Add scope to Exception class methods
Change-Id: I0097aa9a6d9c178c85706b90484f7a68d3ddbc8b
2014-02-24 21:21:09 +01:00
addshore
557af13086 Split Exception.php
Change-Id: I8273b342f8814887b65227457d0a461d7cd31e75
2014-02-24 21:17:59 +01:00