From e455269ba384eab6fcdbf4a74f27da87d7a4a190 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 21 Mar 2013 08:33:19 +0100 Subject: [PATCH] [Debug] ensured that the Debug tools can only be registered once --- src/Symfony/Component/Debug/Debug.php | 18 ++++++++++++++++++ src/Symfony/Component/Debug/ErrorHandler.php | 2 +- .../Component/Debug/ExceptionHandler.php | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Debug/Debug.php b/src/Symfony/Component/Debug/Debug.php index d7edc8d2b257..c265ba65b2c3 100644 --- a/src/Symfony/Component/Debug/Debug.php +++ b/src/Symfony/Component/Debug/Debug.php @@ -20,8 +20,26 @@ */ class Debug { + private static $enabled = false; + + /** + * Enables the debug tools. + * + * This method registers an error handler and an exception handler. + * + * If the Symfony ClassLoader component is available, a special + * class loader is also registered. + * + * @param integer $errorReportingLevel The level of error reporting you wan + */ public static function enable($errorReportingLevel = null) { + if (static::$enabled) { + return; + } + + static::$enabled = true; + error_reporting(-1); ini_set('display_errors', 0); diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index a12a625ed286..b0843c1b01c6 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -47,7 +47,7 @@ class ErrorHandler private static $logger; /** - * Register the error handler. + * Registers the error handler. * * @param integer $level The level at which the conversion to Exception is done (null to use the error_reporting() value and 0 to disable) * diff --git a/src/Symfony/Component/Debug/ExceptionHandler.php b/src/Symfony/Component/Debug/ExceptionHandler.php index 903ae686ca11..cd781b560977 100644 --- a/src/Symfony/Component/Debug/ExceptionHandler.php +++ b/src/Symfony/Component/Debug/ExceptionHandler.php @@ -41,7 +41,7 @@ public function __construct($debug = true, $charset = 'UTF-8') } /** - * Register the exception handler. + * Registers the exception handler. * * @param Boolean $debug *