Commit graph

118 commits

Author SHA1 Message Date
umherirrender
21751b9ba7 echo is not a function
Removed parenthesis after echo

Change-Id: Ia533aedf63b11d15dcc6a5cf75a56134a4b11d86
2013-05-09 19:52:45 +00:00
Kevin Israel
47d1060398 Remove is_numeric check from Title::checkUserBlock
This should allow the usernames of administrators such as "7"
to show correctly on permissions error pages.

I extracted the working code from UserBlockedError::__construct
into a separate method Block::getPermissionsError, called from
both places with context provided as an argument.

Additional changes to get the test suite to pass are included.

Bug: 46768
Change-Id: I49d973992a99e03b4e8de112b47b737037a85338
2013-04-24 01:05:23 +00:00
umherirrender
ef2f507d23 Fixed spacing in files direct in includes folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: Ibb8dd102db045522d12ff939075ba7420d95ab6b
2013-04-21 06:38:49 +00:00
umherirrender
15abcf71ca Added/Removed spaces around string concatenation
And added/removed spaces around some other tokens,
like +, -, *, /, <, >, =, !

Fixed windows newline style

Change-Id: I0b9c8c408f3f6bfc0d685a074d7ec468fb848fc8
2013-04-13 13:36:24 +02:00
Timo Tijhof
acb292d733 phpcs: Fix Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore violations
ERROR: Closing brace must be on a line by itself
Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore

- For non-empty scopes it means the closing brace must be on a separate
  line. This is already the case in most classes in some cases the "lazy
  closing" is still used.
  array(
   'x' ); // Moved } to next line
  function () { return 'x'; } // Moved } to next line
  case 1:
    stuff; break; // Moved break to next line
- For empty function it serves as a visual distinction between there not
  being a scope block / function body and there being an empty function
  body.
  function foo(); // No body
  function foo() {} // Empty body - violation
  function bar() { // Empty body corrected
  }

Change-Id: I0310ec379c6d41cc7d483671994d027a49f32164
2013-04-11 07:34:41 +00:00
Hashar
572ee81c0b Revert "Remove is_numeric check from Title::checkUserBlock"
Breaks unit testing (see bug 47031). The commit managed to land in
the branch because of a bug in Jenkins (bug 46723).

This reverts commit 8cc0b601aa

Change-Id: I4b3fadccaae9c35964a0c47d63b22c4f35148a24
2013-04-09 08:20:12 +00:00
Kevin Israel
8cc0b601aa Remove is_numeric check from Title::checkUserBlock
This should allow the usernames of administrators such as "7"
to show correctly on permissions error pages.

I extracted the working code from UserBlockedError::__construct
into a separate method Block::getPermissionsError, called from
both places with context provided as an argument.

Bug: 46768
Change-Id: Ic3fa926a5a4c109faff35fffbccb60fb06ea4a18
2013-04-09 02:40:35 +00:00
Platonides
29f713ed10 Specify the utf-8 charset on error messages.
Although the contents of error messages are English text,
and thus it's irrelevant that it gets interpreted as
iso-8859-1 instead of utf-8, $wgSitename is printed by
DBConnectionError::searchForm(), and that can contain utf-8.

Cached pages may also be in utf-8.

Change-Id: I81c02493f0824cb010c80f4356f338787d78df6b
2013-04-04 01:28:33 +02:00
Brad Jorsch
fb04d38e23 (bug 44111) ErrorPageError log messages should be in English
We want log messages to be in English. ErrorPageError, however, will log
the messages using the language of the current user. This isn't often
noticed, because the normal page view code path doesn't log
ErrorPageError and the API doesn't usually have ErrorPageError thrown in
the first place.

The fix is simple enough: in the constructor, create a new Message
object and call ->inLanguage( 'en' ) on it. And, for good measure,
->useDatabase( false ) so customizations on the local wiki won't show up
in the log files either.

Since ErrorPageError already overrides report(), that will take care of
still showing the expected language to the end user.

Bug: 44111
Change-Id: I9a6ab43d63e76fa9708b62e32ddc3262aff282f7
2013-03-28 02:39:05 +00:00
umherirrender
6c278b6d7e fix some spacing
* Removed spaces around array index
* Removed double spaces or added spaces to begin or end of function
  calls, method signature, conditions or foreachs
* Added braces to one-line ifs
* Changed multi line conditions to one line conditions
* Realigned some arrays

Change-Id: Ia04d2a99d663b07101013c2d53b3b2e872fd9cc3
2013-03-25 22:22:46 +00:00
Yuri Astrakhan
9506e3d812 Spellchecked /includes directory
* Ran spell-checker over code comments in /includes/
* A few spellchecking fixes for wfDebug() calls

Found one very strange (NOOP?) line in Linker.php - see "TODO: BUG?"

Change-Id: Ibb86b51073b980eda9ecce2cf0b8dd33f058adbf
2013-03-13 03:42:41 -04:00
Tyler Anthony Romeo
4dcc7961df Fixed @param tags to conform with Doxygen format.
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.

Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
2013-03-11 13:15:01 -04:00
umherirrender
d63121016d fix some spacing
Added/removed spaces around logical/arithmetic operator
Reduced multiple empty lines to one empty line
Removed wrong tabs before comments at end of line
Removed too many spaces in assigments

Change-Id: I2bba4e72f9b5f88c53324d7b70e6042f1aad8f6b
2013-03-07 17:53:21 +01:00
umherirrender
1044b0b8df fix some spacing
Change-Id: I8f976013f33c5818e4402604fe8610aa3f43b0c6
2013-02-04 20:18:33 +00:00
daniel
8e7f3b79d7 Add return to HttpError::getStatusCode.
Oops...

Change-Id: I4fb5bd11be340870d903d62e1329b1181f72e695
2013-02-01 16:17:38 +01:00
daniel
2e8e4478af Add getters to HttpError, to use it in tests.
Change-Id: I1165063ebdbcc29ae26998bd6ab74782dc0ecdc5
2013-01-30 22:45:32 +01:00
daniel
7448da5ddc Make HttpError set actual HTTP error code.
Previsouly, HttpError would set a Status header with the desired code,
but would not change the actual HTTP/1.1 header to include that code.

Change-Id: I2f68b1fa410b3619c5be3e82b64f99df97b9415a
2013-01-29 17:02:19 +01:00
umherirrender
6fbbbd17ca fix some spacing
Change-Id: Ie7bb35871cc99237f3a655f7db22ca1f0646df5e
2013-01-27 14:21:50 +01:00
S Page
755d9563c6 Typo in comment's Example code.
Patch 2: fix both comment Examples, rephrase comment, fix a few typos.

Change-Id: Id57d9307a3f613445faacdea8c9a4e195ad3987d
2012-11-26 21:23:40 -08:00
Alexandre Emsenhuber
2393a58ddc Don't exit too quickly when reporting an exception.
MWExceptionHander::handle() already exist at the end of its task,
so there's no need to have other die() calls.

There were some problems with that:
- wfLogProfilingData() was only called after reporting some exception
- MWExceptionHandler::report() was not consistent between web and
  command-linerequests
- MWException::reportHTML() was also not consistent when using the
  OutputPage object or not

Also removed MWExceptionHander::escapeEchoAndDie() since it's not needed anymore.

Change-Id: Ibb679c425ef0271a65f623c7b8541ec9bec70eb0
2012-09-09 15:12:02 +02:00
Siebrand Mazeland
c6b74865fe Fix documentation.
Change-Id: I43f4ae1248bc4a24cf127fadb6e616da8d4516e2
2012-08-27 11:48:47 +02:00
Siebrand Mazeland
6fe1f0509b Replace deprecated wfMsg* calls with Message class calls.
Doing this in steps of roughly 100 changes per commit, so that it remains reviewable.

Change-Id: Ib15e670badd3f6aecae8b60e2f9129a31341ce16
2012-08-21 18:38:44 +02:00
Siebrand Mazeland
9ff9aaae63 Fix typo: occured -> occurred.
Change-Id: I5e66fdd52791487f81796ae1965ac31c94b36182
2012-08-10 10:59:55 +02:00
Alexandre Emsenhuber
0b2d671d2c @since to subclasses of MWException
Change-Id: I9f87ba2ab00e4a68313a19823a20b10d55073e84
2012-08-02 10:36:56 +02:00
Alexandre Emsenhuber
ae927637d3 Documentation improvements in Exception.php.
Change-Id: I645025c9acbb91df48bb0f1ee3859840195c5e56
2012-07-12 21:59:14 +02:00
Alexandre Emsenhuber
bc470f3661 Send correct HTML when reporting a MWException object and the OuputPage object cannot be used.
Currently only the body was sent, without doc type, <html>, <head> or <body> items.

Change-Id: I2d5cc3f69f55d0e1b212148f57f736f100bd2554
2012-07-06 20:57:12 +02:00
Antoine Musso
b1c1448d98 (bug 37627) generic exception for not logged in users
We have various place in MediaWiki core and in extensions which are
showing anonymous user a very standard error page about them not being
logged in. Each developer ends up writing its own because we do not
provide a generic error, that is what this patch does.

This UserNotLoggedIn exception, when called, will show the usual
ErrorPage with a default title and default reason text. That makes it as
easy to use as doing:

 if( $user->isAnon() ) {
 	throw new UserNotLoggedIn();
 }

One can override the default reason by passing a message key as the
first parameter:

 if( $user->isAnon() ) {
 	throw new UserNotLoggedIn( 'nologin-reason-text' );
 }

In that case, the page title will still be the default 'Not Logged In.'

Change-Id: Id81272995627bf0f5bbef785230a8e6e4e8582ca
2012-06-26 16:03:42 +02:00
Antoine Musso
af4b004485 document ErrorPageError constructor parameters
ErrorPageError can receive either a message object or a message key

Change-Id: I8e51d802c2ab333fd61069a713c39dda0f418232
2012-06-26 16:00:54 +02:00
awjrichards
c29fd59775 Big oops - merged to wrong branch.
Revert "Revert to arbitrarily old point before initial remote branch creation to help clean up"

This reverts commit ee0d3d330f
2012-06-05 22:58:54 +00:00
awjrichards
ee0d3d330f Revert to arbitrarily old point before initial remote branch creation to help clean up
Change-Id: I41a3d1e55d3ea9dffa42451237fe065f9334361d
2012-06-02 08:43:04 -07:00
Platonides
3e59f15bb0 Set the status code to 500 on exceptions.
Should fix bug 37140, scripts served through
action=raw failing due to being served a html
error page.
As well as such as giving a better behavior
such as for search engines.
This could affect IE users by showing them
smart errors instead of the content, though.

Change-Id: I5d680fe10db6d61d91e898323bd5fb755a07135d
2012-05-31 19:15:33 +02:00
Alexandre Emsenhuber
3bbda787b8 Added missing GPLv2 headers in some places.
Also made file/class documentation more consistent.

Change-Id: Ic1ba00472ef62fa4fd746f8f590fe694d490ecd9
2012-05-20 17:56:43 +02:00
Tim Starling
e2aa8b4978 Don't log HttpError
Fix for r97314: don't log HttpError exceptions to the exception log channel. Do
this by overriding MWException::report() rather than
MWException::reportHTML(), same as every other child class in
Exception.php.

Change-Id: I3fb2b0ca9b0e7c67c210078d1fd90e1430be39df
2012-05-15 15:04:40 +10:00
Tim Starling
70841c5867 Make $wgShowExceptionDetails=false more feasible for production
* Make the HTML error message prettier, with a nice red box and
  instructions to modify LocalSettings.php hidden in an HTML comment.
* Show the exception class name, since that's pretty safe.
* Show a random "log ID" to the user, and also send it to the exception
  log, to allow easier log correlation.
* Optionally send backtraces to the error log, enabled by default.

Change-Id: Ie92e46032b3d194c4217119567847a38a53be577
2012-05-08 10:01:13 +10:00
Reedy
2edbe14e39 Normalising return statements
Add/improve parameter documentation

Change-Id: I4c7fa319be60a47b7fcd81131458577bccb009fb
2012-04-27 16:40:14 +01:00
Antoine Musso
6d915be35f update html DOCTYPE sent by HttpError exception
Follow up r110486, which updated doctype sent by wfHttpError()

Change-Id: I0e89420dd95edcf1ac76e3984b36f92df11cdb3f
2012-04-20 14:55:23 +02:00
Reedy
8c84c3879b parent::report() returns nothing, so don't attempt to return its value
Change-Id: Id506d51818bf101a68fe8b028df2062ed221cdf9
2012-04-07 19:39:43 +01:00
Max Semenik
d3e0e88f18 Don't output skinned errors in case of unhandled API exceptions 2012-02-20 19:19:52 +00:00
Antoine Musso
a15b11d3a5 bug 33646 Badtitle error page now emits a 400 HTTP status.
Sending a 200 OK status on bad title, prevents mobile browsers to
actually now the page is an error page.

Tested using:
 curl -I http://localhost/wiki/\]\]
 curl -I http://localhost/wiki/Special:BadTitle
2012-01-25 10:51:37 +00:00
Platonides
55b35bdd20 On errors not using OutputPage, Content-Type header wasn't set,
although we output localised UTF-8 messaged.
2011-11-16 16:53:12 +00:00
Alexandre Emsenhuber
f2d0453f9d * Made PermissionsError exception accept an optional second parameter for the description of the errors (as returned by Title::getUserPermissionsErrors())
* PermissionsError now calls OutputPage::showPermissionsErrorPage() to display the error (this is needed to make the item above work correctly)
* Removed the override of the HTML title in OutputPage::showPermissionsErrorPage() so that it shows "Permission errors - Sitename" instead of simply "Permission errors" for consistency with the other things
* Pass the error array returned by Title::getUserPermissionsErrors() to PermissionsError where available
* Converted direct calls to OutputPage::showPermissionsErrorPage() to throw an PermissionsError error instead
* Added 'action-rollback' message that will be displayed when accessing action=rollback without sufficient rights
* Changed getRestriction() in subclasses of Action to return null when they previously returned 'read' so that user rights can be check with Title::getUserPermissionsErrors()
* Reordered checks to do first user rights, then block (if needed) and finally read only (also if needed) so that users don't think the error is temporary when they both don't have right and the database is locked
2011-11-02 15:30:55 +00:00
Aaron Schulz
db186619cf FR r101442: forgot to replace another getBlocker()->getName() with getByName() 2011-11-01 00:16:35 +00:00
Aaron Schulz
7916d730ae (bug 31739) Made Block code support ipb_by = 0 convention with for foreign users again, as it did pre 1.18. The byText param has been restored in the Block() constructor as CentralAuth still uses it. Some callers have been updated to reflect the fact that getBlocker() may be a local User or a string username.
Ideally, we might have a ForeignUser class and a generic User interface...but this will do for now.
2011-11-01 00:11:53 +00:00
Alexandre Emsenhuber
4b661607eb * Factorise the code used to prepare the OutputPage object to display an error page in OutputPage::prepareErrorPage()
* Changed default value of OutputPage::getPageTitle() to match the value of the 'internalerror' message
2011-10-28 15:45:54 +00:00
Sam Reed
96641da58e Add, update, tweak documentation
Fix document comment blocks

Tweak some returns
2011-10-26 03:44:47 +00:00
Sam Reed
9ceb44a598 Fixup some assignments in conditionals
Add/normalise some more return statements
2011-10-16 03:27:12 +00:00
Sam Reed
27665d27ae Update some deprecated code
Documentation

Fix "/*" comments to "/**"

Flesh out some missing returns, change some return types
2011-10-14 21:18:38 +00:00
Sam Reed
90e74042b4 Fix comment blocks that start /* to /** 2011-10-11 18:30:50 +00:00
Alexandre Emsenhuber
ec9b551ca9 * Added HttpError exception as replacement for wfHttpError(); changed alls core calls to it except AjaxDispatcher.php
* Changed FeedUtils' call to it to be similar than feeds are completely disabled
* Use local context instead of global variables in Special:Userlogout
2011-09-16 18:50:13 +00:00
Chad Horohoe
69eb4e23d6 Don't attempt to get a request url from a FauxRequest 2011-09-16 15:21:06 +00:00