Commit graph

81 commits

Author SHA1 Message Date
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
Roan Kattouw
7d1384b58d Followup r85994: eliminate code duplication introduced by this revision, instead make OutputPage::showErrorPage() accept Message objects 2011-08-25 10:13:30 +00:00
Alexandre Emsenhuber
77a3987052 Moved wfGetIP() to WebRequest::getIP():
* Changed all calls in core to the latter
* Also marked wfGetForwardedFor() as deprecated
* Moved wfGetIP() tests to WebRequestTest
2011-08-18 20:03:30 +00:00
Brion Vibber
3cfb43ee4f Revert r94041: PHP Notice: Undefined index: SERVER_PROTOCOL in /home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/includes/Exception.php on line 185
This code appears to be trying to output something like 'HTTP/1.1 500 MediaWiki Error', but using $_SERVER['SERVER_PROTOCOL']. And it seems to output it on things that run in phpunit tests.
Seems pretty broken?
2011-08-15 21:04:11 +00:00
Alexandre Emsenhuber
952f921981 Readd basic headers and <html>...</html> arround error contents that was removed in r90993. This caused display errors of UTF-8 characters due to the lack of these things in a DBConnectionError exception. 2011-08-07 12:28:58 +00:00
Antoine Musso
be9b7258e7 Typo in message autoblockedtext
Follow up r85951
2011-07-27 19:46:56 +00:00
Chad Horohoe
92ba47064b * Remove Exception.php's reliance on wfDie(), as well as the awful constant MEDIAWIKI_INSTALL (holdover from old installer)
* Rm checking for MEDIAWIKI_INSTALL in wfOut(), no codepath leads here from the installer anymore
2011-06-28 19:46:23 +00:00
Chad Horohoe
1ed04e266b @ingroup things 2011-05-30 00:21:06 +00:00
Chad Horohoe
0bafff5109 Misc. exception handling cleanup--moved it out of global function namespace
Also removed htmlHeader() and htmlFooter() since it has zero callers anywhere.
Not sure why useOutputPage() was checking isArticleRelated(), we should be able do use it with other stuff too
2011-05-30 00:18:10 +00:00
Chad Horohoe
3e11266ae5 $wgArticle is deprecated! Possible removal in 1.20 or 1.21!
* Encapsulate index.php in wfIndexMain() (similar to r77873)
* Kill $wgArticle check in Exception, not necessary anymore
* Kill $wgArticle in Setup, also not necessary
* Add angry note about $wgArticle to rebuildFileCache.
* Remove note about $wgArticle in Parser since it's dying anyway
2011-05-22 17:59:47 +00:00
Happy-melon
068f89d108 Follow-up r85918:
* Clean up the ugly adding-then-removing-then-readding HTML <head> and <body> tags in DBConnectionError, deprecates MWException::htmlBodyOnly()
* Also deprecates MWException::htmlHeader(), removes code duplication since MWException::reportHTML() can safely call wfDie() and get an output format appropriate for the entry point
* Copy a couple of HTML headers (Cache-control, Pragma and Content-type) to the wfDie() implementation.
2011-05-07 14:01:49 +00:00
Happy-melon
84f048c68a (bug 28834) Restore nl2br() wrappers removed in r85918. 2011-05-07 13:24:47 +00:00
Sam Reed
15df9a9d5c Kill off the long deprecated $wgInputEncoding and $wgOutputEncoding globals 2011-05-06 22:09:47 +00:00
Alexandre Emsenhuber
5b1ecf951f * Use wfMsgNoTrans() instead of wfMsgReal()
* Simplify getPageTitle()
* Remove a useless call to getPageTitle(), <img> tag does not have content
2011-04-24 16:53:46 +00:00
Happy-melon
f144bcfb6b Add ThrottledError to throw when the user hits a rate limit. 2011-04-18 22:29:23 +00:00
Happy-melon
72feb39457 Unbundle OutputPage::showErrorPage() in Exception.php to allow ErrorPageError objects to be passed a Message object for a more complicated display. 2011-04-13 22:30:13 +00:00
Happy-melon
47e3f922da Implement user-is-blocked and wiki-is-read-only as exceptions. 2011-04-13 14:30:55 +00:00
Happy-melon
2e1e9bf0e6 allow methods to generate a "user does not have required permissions" error by throwing an exception rather than calling $wgOut->permissionRequired(). Currently somewhat circular as the exception goes back to OutputPage::showErrorPage(), but hopefully that global dependency can be reduced in future. 2011-04-12 22:59:17 +00:00
Happy-melon
938a8eb347 Improvements to handling of 'catastrophic' errors, like unsupported PHP versions, no MySQL functions, no LocalSettings, etc.
* Fix parsing of the three major entry points (index.php, api.php, load.php) back to PHP 4.4.9.  We don't care what happens if you actually try to run these files on old versions, but the entry files need to parse correctly.
* consign /includes/templates/PHP4.php and /includes/templates/NoLocalSettings.php to the fiery pit of hell where they belong.
* Prevent loading of any other files for PHP < 5.  WebStart.php was rendered unparseable in PHP 4 by the introduction of try/catch blocks in r85327.
* Die outright with a pretty error message on PHP < 5.2.3 as well as PHP 4.  All versions of PHP below that throw parse errors of various sorts.
* Reimplement wfDie() to provide an entry-point-dependent die-with-readable-error-message function (for instance, we want a pretty human-readable page in index.php, something wrapped in CSS/JS /*...*/ comment block in load.php, etc).  
* Standardise the appearance of the catastrophic errors thrown at the top of the stack with the ones lower down (exception-within-exception, etc).  There isn't really a way to do this without duplication, AFAICT.
2011-04-12 20:38:16 +00:00
Niklas Laxström
c16556dd84 Partial revert of r79903, unstubbing needs localisation cache which might need database 2011-01-09 18:31:52 +00:00
Niklas Laxström
8b32822137 Follow-up r79880: check if $wgLang can be used.
Changed the checks in Database.php to use is_object because of stub objects
2011-01-09 17:08:40 +00:00
Niklas Laxström
111a166e01 * (bug 26638) Database error pages display correctly in RTL languages 2011-01-09 10:36:13 +00:00
Alexandre Emsenhuber
f3aa97bd5f Fix for r33432: isArticle() is to check if the content displayed is the one of the article, isArticleRelated() is more appropriate here 2011-01-08 19:21:37 +00:00
Platonides
6e81d60086 Fix potential html injection when the database server isn't available (bug 26164).
Wikis which set $wgServer in their LocalSettings or are in a virtual
host would never be vulnerable.
For sites which show the wiki in the default host, it will depend on how
forgiving is their webserver and php stack for that garbled input, although 
some kind of foolable proxy —moreover wrongly caching errors (or the default 
output buffering is disabled and something incorrectly sent a previous text)—
would also need to be present in order to make that useful for a 
potential attacker.
2010-11-29 16:34:28 +00:00
Sam Reed
39c005ca79 bug 25517 Assignment in conditions should be avoided/ http://www.mediawiki.org/wiki/Manual:Coding_conventions#Assignment_expressions 2010-11-01 00:07:17 +00:00
Alexandre Emsenhuber
7e995c96f7 Added wfDeprecated() to wfAbruptExit() and wfErrorExit() and removed a comment that mentioned it 2010-10-03 08:42:38 +00:00
Siebrand Mazeland
64fdb18e74 More whitespace updates for files touched in r72342:
* stylize.php run
* code formatting updates
* updated a few comments
* added braces where not used
2010-09-04 13:48:16 +00:00
Mark A. Hershberger
5dbbca7331 w/s changes 2010-09-04 01:06:34 +00:00
Alexandre Emsenhuber
5be509b0c1 * Standardised file description headers
* Added some descriptions
* Added @file where needed
2010-08-08 14:23:14 +00:00
Alexandre Emsenhuber
5f62d63483 Added a note to set $wgShowExceptionDetails = true; in LocalSettings.php to get details when encoutring an second exception in the exception handler 2010-08-07 18:32:39 +00:00
Sam Reed
04f68827d0 Removal of unused globals
Removal of one setting of a variable to '', then not using further
2010-07-24 19:11:52 +00:00
Alexandre Emsenhuber
ebe3cb7362 Fixed some doxygen warnings 2010-03-05 21:39:21 +00:00
Tim Starling
1f79ae389d * Re-added $wgMessageCache->addMessages(), there are still some extensions (in and out of subversion) that rely on it. Call wfDeprecated().
* Made wfDeprecated() issue a notice only once for each function name instead of every time the function is called.
* Added exceptions for malformed keys input to $wgMessageCache->get(), per CR comments on r52503
* Fixed notice from MWException::useMessageCache()
2009-07-03 06:19:39 +00:00
Andrew Garrett
160936a8dd Revert unintended core changes in r52627 2009-07-01 17:48:30 +00:00
Andrew Garrett
ca329c7acb Bring up reply and new thread forms with AJAX where available. Still submits with a regular POST, because I've just spent a day on AJAX and that would be at least another day or two. 2009-07-01 17:46:35 +00:00
Tim Starling
23cfebd3d2 * Introduced a new system for localisation caching. The system is based around fast fetches of individual messages, minimising memory overhead and startup time in the typical case. It handles both core messages (formerly in Language.php) and extension messages (formerly in MessageCache.php). Profiling indicates a significant win for average throughput.
* The serialized message cache, which would have been redundant, has been removed. Similar performance characteristics can be achieved with $wgLocalisationCacheConf['manualRecache'] = true;
* Added a maintenance script rebuildLocalisationCache.php for offline rebuilding of the localisation cache.
* Extension i18n files can now contain any of the variables which can be set in Messages*.php. It is possible, and recommended, to use this feature instead of the hooks for special page aliases and magic words. 
* $wgExtensionAliasesFiles, LanguageGetMagic and LanguageGetSpecialPageAliases are retained for backwards compatibility. $wgMessageCache->addMessages() and related functions have been removed. wfLoadExtensionMessages() is a no-op and can continue to be called for b/c. 
* Introduced $wgCacheDirectory as a default location for the various local caches that have accumulated. Suggested $IP/cache as a good place for it in the default LocalSettings.php and created this directory with a deny-all .htaccess.
* Patched Exception.php to avoid using the message cache when an exception is thrown from within LocalisationCache, since this tends to fail horribly.
* Removed Language::getLocalisationArray(), Language::loadLocalisation(), Language::load()
* Fixed FileDependency::__sleep()
* In Cdb.php, fixed newlines in debug messages

In MessageCache::get(): 
* Replaced calls to $wgContLang capitalisation functions with plain PHP functions, reducing the typical case from 99us to 93us. Message cache keys are already documented as being restricted to ASCII.
* Implemented a more efficient way to filter out bogus language codes, reducing the "foo/en" case from 430us to 101us
* Optimised wfRunHooks() in the typical do-nothing case, from ~30us to ~3us. This reduced MessageCache::get() typical case time from 93us to 38us.
* Removed hook MessageNotInMwNs to save an extra 3us per cache hit. Reimplemented the only user (LocalisationUpdate) using the new hook LocalisationCacheRecache.
2009-06-28 07:11:43 +00:00
Alexandre Emsenhuber
7248906455 * (bug 18289) Database connection error page now returns correct HTML
Changed MWException::htmlHeader() and MWException::htmlFooter() to return the HTML rather than echo()'ing directly
2009-04-02 20:38:25 +00:00
Aaron Schulz
fcd22b9a84 More visual and xhtml fixes for file cache failback 2009-03-14 03:16:05 +00:00