From 0cc73bd7020ca53d7e296b9f5842331fb0d54cb1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 8 Nov 2012 20:19:08 +0000 Subject: [PATCH] The error handler does now take care of not out-putting the error message to the browser in installation phase --- inc/handler.php | 13 +++++++++++-- inc/install-functions.php | 27 --------------------------- 2 files changed, 11 insertions(+), 29 deletions(-) diff --git a/inc/handler.php b/inc/handler.php index 84176c10b7..fe9149c99e 100644 --- a/inc/handler.php +++ b/inc/handler.php @@ -50,8 +50,17 @@ function __errorHandler ($errno, $errstr, $errfile, $errline) { $errline ); - // Output message to user and die - reportBug($errfile, $errline, $message); + // Is installation phase? + if (isInstallationPhase()) { + // Log error message + logDebugMessage($errfile, $errline, $message); + } else { + // Output message to user and die + reportBug($errfile, $errline, $message); + } + + // Always return false + return FALSE; } // Init error handler diff --git a/inc/install-functions.php b/inc/install-functions.php index 3dddbb89a4..8ef45388ab 100644 --- a/inc/install-functions.php +++ b/inc/install-functions.php @@ -443,20 +443,11 @@ function isInstallerPostDatabaseConfigValid ($currentTab) { return FALSE; } // END - if - // Restore PHP's own error handler - if (!restore_error_handler()) { - // This is fatal - reportBug(__FUNCTION__, __LINE__, 'Could not unregister error handler.'); - } // END - if - // Try to connect to the database $linkResource = SQL_CONNECT(postRequestElement('mysql_host'), postRequestElement('mysql_login'), postRequestElement('mysql_password1'), __FUNCTION__, __LINE__); // Is the link up if (!is_resource($linkResource)) { - // Restore own error handler again - set_error_handler('__errorHandler'); - // Cannot connect to database $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_CONNECT_ERROR--}'; array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_login', 'mysql_password1', 'mysql_password2'); @@ -465,9 +456,6 @@ function isInstallerPostDatabaseConfigValid ($currentTab) { // Then attempt to select the database if (!SQL_SELECT_DB(postRequestElement('mysql_dbase'), __FUNCTION__, __LINE__)) { - // Restore own error handler again - set_error_handler('__errorHandler'); - // Could not find database $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_SELECT_FAILED--}'; array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_dbase'); @@ -478,25 +466,16 @@ function isInstallerPostDatabaseConfigValid ($currentTab) { setConfigEntry('__DB_NAME' , postRequestElement('mysql_dbase')); setConfigEntry('_MYSQL_PREFIX', postRequestElement('mysql_prefix')); - // Restore own error handler again - set_error_handler('__errorHandler'); - // Get an array of all supported engines $engines = getArrayFromSupportedSqlEngines(); // Is this an array? if (!is_array($engines)) { - // Restore own error handler again - set_error_handler('__errorHandler'); - // Something bad happened $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_ENGINES_SQL_ERROR--}'; array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_type'); return FALSE; } elseif (count($engines) == 0) { - // Restore own error handler again - set_error_handler('__errorHandler'); - // No engine is active $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_NO_ENGINES_ACTIVE--}'; array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_type'); @@ -518,9 +497,6 @@ function isInstallerPostDatabaseConfigValid ($currentTab) { // So, is the engine found? if ($engineValid === FALSE) { - // Restore own error handler again - set_error_handler('__errorHandler'); - // Requested engine is not active $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_ENGINE_UNSUPPORTED--}'; array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_type'); @@ -579,9 +555,6 @@ function isInstallerPostDatabaseConfigValid ($currentTab) { // Disconnect here, we don't need idle database connections laying around SQL_CLOSE(__FUNCTION__, __LINE__); - // Restore own error handler again - set_error_handler('__errorHandler'); - // If the status is true, disconnect the database if ($isValid === FALSE) { // Still something bad happened (e.g. tables found) -- 2.39.5