X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fexception%2FMWExceptionHandler.php;h=b4e483bf53289f935f3d49a94b78d53f60fd1c9d;hb=0fb54f19ad48232d694deebd1c45b9f5adec5552;hp=951498e53733dce5e573221966d724b661a65671;hpb=1d5344025f02e1b2b9646c6d88083255edd87f58;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/exception/MWExceptionHandler.php b/includes/exception/MWExceptionHandler.php index 951498e537..b4e483bf53 100644 --- a/includes/exception/MWExceptionHandler.php +++ b/includes/exception/MWExceptionHandler.php @@ -74,9 +74,32 @@ class MWExceptionHandler { * Install handlers with PHP. */ public static function installHandler() { + // This catches: + // * Exception objects that were explicitly thrown but not + // caught anywhere in the application. This is rare given those + // would normally be caught at a high-level like MediaWiki::run (index.php), + // api.php, or ResourceLoader::respond (load.php). These high-level + // catch clauses would then call MWExceptionHandler::logException + // or MWExceptionHandler::handleException. + // If they are not caught, then they are handled here. + // * Error objects (on PHP 7+), for issues that would historically + // cause fatal errors but may now be caught as Throwable (not Exception). + // Same as previous case, but more common to bubble to here instead of + // caught locally because they tend to not be safe to recover from. + // (e.g. argument TypeErorr, devision by zero, etc.) set_exception_handler( 'MWExceptionHandler::handleUncaughtException' ); + + // This catches: + // * Non-fatal errors (e.g. PHP Notice, PHP Warning, PHP Error) that do not + // interrupt execution in any way. We log these in the background and then + // continue execution. + // * Fatal errors (on HHVM in PHP5 mode) where PHP 7 would throw Throwable. set_error_handler( 'MWExceptionHandler::handleError' ); + // This catches: + // * Fatal error for which no Throwable is thrown (PHP 7), and no Error emitted (HHVM). + // This includes Out-Of-Memory and Timeout fatals. + // // Reserve 16k of memory so we can report OOM fatals self::$reservedMemory = str_repeat( ' ', 16384 ); register_shutdown_function( 'MWExceptionHandler::handleFatalError' ); @@ -462,22 +485,6 @@ TXT; }, $trace ); } - /** - * Get the ID for this exception. - * - * The ID is saved so that one can match the one output to the user (when - * $wgShowExceptionDetails is set to false), to the entry in the debug log. - * - * @since 1.22 - * @deprecated since 1.27: Exception IDs are synonymous with request IDs. - * @param Exception|Throwable $e - * @return string - */ - public static function getLogId( $e ) { - wfDeprecated( __METHOD__, '1.27' ); - return WebRequest::getRequestId(); - } - /** * If the exception occurred in the course of responding to a request, * returns the requested URL. Otherwise, returns false.