Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.385 diff -u -r1.385 bootstrap.inc --- includes/bootstrap.inc 6 May 2010 05:59:30 -0000 1.385 +++ includes/bootstrap.inc 11 May 2010 10:26:08 -0000 @@ -1944,11 +1944,10 @@ catch (Exception $exception2) { // Another uncaught exception was thrown while handling the first one. // If we are displaying errors, then do so with no possibility of a further uncaught exception being thrown. - $error_level = variable_get('error_level', ERROR_REPORTING_DISPLAY_ALL); - if ($error_level == ERROR_REPORTING_DISPLAY_ALL || (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update')) { - print 'Additional uncaught exception thrown while handling exception.

'; - print 'Original
' . _drupal_render_exception_safe($exception) . '

'; - print 'Additional
' . _drupal_render_exception_safe($exception2) . '

'; + if (error_displayable()) { + print '

Additional uncaught exception thrown while handling exception.

'; + print '

Original

' . _drupal_render_exception_safe($exception) . '

'; + print '

Additional

' . _drupal_render_exception_safe($exception2) . '


'; } } } @@ -2808,11 +2807,10 @@ } catch (Exception $exception) { // If we are displaying errors, then do so with no possibility of a further uncaught exception being thrown. - $error_level = variable_get('error_level', ERROR_REPORTING_DISPLAY_ALL); - if ($error_level == ERROR_REPORTING_DISPLAY_ALL || (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update')) { - require_once DRUPAL_ROOT . '/includes/errors.inc'; - print 'Uncaught exception thrown in shutdown function.

'; - print _drupal_render_exception_safe($exception) . '

'; + require_once DRUPAL_ROOT . '/includes/errors.inc'; + if (error_displayable()) { + print '

Uncaught exception thrown in shutdown function.

'; + print '

' . _drupal_render_exception_safe($exception) . '


'; } } } Index: includes/errors.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/errors.inc,v retrieving revision 1.5 diff -u -r1.5 errors.inc --- includes/errors.inc 11 Apr 2010 18:33:43 -0000 1.5 +++ includes/errors.inc 11 May 2010 10:26:08 -0000 @@ -139,6 +139,26 @@ } /** + * Determine whether an error should be displayed. + * + * When in mainenance mode or when error_level is ERROR_REPORTING_DISPLAY_ALL, + * all errors should be displayed. For ERROR_REPORTING_DISPLAY_SOME, $error + * will be examined to determine if it should be displayed. + * + * @param $error + * Optional error to examine for ERROR_REPORTING_DISPLAY_SOME. + * @return + * TRUE if an error should be displayed. + */ +function error_displayable($error = NULL) { + $error_level = variable_get('error_level', ERROR_REPORTING_DISPLAY_ALL); + + return (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update') || + ($error_level == ERROR_REPORTING_DISPLAY_ALL) || ($error_level == ERROR_REPORTING_DISPLAY_SOME && + isset($error) && $error['%type'] != 'Notice' && $error['%type'] != 'Strict warning'); +} + +/** * Log a PHP error or exception, display an error page in fatal cases. * * @param $error @@ -200,9 +220,7 @@ else { // Display the message if the current error reporting level allows this type // of message to be displayed, and unconditionnaly in update.php. - $error_level = variable_get('error_level', ERROR_REPORTING_DISPLAY_ALL); - $display_error = $error_level == ERROR_REPORTING_DISPLAY_ALL || ($error_level == ERROR_REPORTING_DISPLAY_SOME && $error['%type'] != 'Notice' && $error['%type'] != 'Strict warning'); - if ($display_error || (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update')) { + if (error_displayable($error)) { $class = 'error'; // If error type is 'User notice' then treat it as debug information Index: includes/session.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/session.inc,v retrieving revision 1.83 diff -u -r1.83 session.inc --- includes/session.inc 1 May 2010 08:12:22 -0000 1.83 +++ includes/session.inc 11 May 2010 10:26:08 -0000 @@ -140,46 +140,58 @@ function _drupal_session_write($sid, $value) { global $user, $is_https; - if (!drupal_save_session()) { - // We don't have anything to do if we are not allowed to save the session. - return; - } - - $fields = array( - 'uid' => $user->uid, - 'cache' => isset($user->cache) ? $user->cache : 0, - 'hostname' => ip_address(), - 'session' => $value, - 'timestamp' => REQUEST_TIME, - ); - $key = array('sid' => $sid); - if ($is_https) { - $key['ssid'] = $sid; - $insecure_session_name = substr(session_name(), 1); - // The "secure pages" setting allows a site to simultaneously use both - // secure and insecure session cookies. If enabled, use the insecure session - // identifier as the sid. - if (variable_get('https', FALSE) && isset($_COOKIE[$insecure_session_name])) { - $key['sid'] = $_COOKIE[$insecure_session_name]; + // The exception handler is not active at this point, so we need to do it manually. + try { + if (!drupal_save_session()) { + // We don't have anything to do if we are not allowed to save the session. + return; } - } - db_merge('sessions') - ->key($key) - ->fields($fields) - ->execute(); - // Last access time is updated no more frequently than once every 180 seconds. - // This reduces contention in the users table. - if ($user->uid && REQUEST_TIME - $user->access > variable_get('session_write_interval', 180)) { - db_update('users') - ->fields(array( - 'access' => REQUEST_TIME - )) - ->condition('uid', $user->uid) + $fields = array( + 'uid' => $user->uid, + 'cache' => isset($user->cache) ? $user->cache : 0, + 'hostname' => ip_address(), + 'session' => $value, + 'timestamp' => REQUEST_TIME, + ); + $key = array('sid' => $sid); + if ($is_https) { + $key['ssid'] = $sid; + $insecure_session_name = substr(session_name(), 1); + // The "secure pages" setting allows a site to simultaneously use both + // secure and insecure session cookies. If enabled, use the insecure session + // identifier as the sid. + if (variable_get('https', FALSE) && isset($_COOKIE[$insecure_session_name])) { + $key['sid'] = $_COOKIE[$insecure_session_name]; + } + } + db_merge('sessions') + ->key($key) + ->fields($fields) ->execute(); - } - return TRUE; + // Last access time is updated no more frequently than once every 180 seconds. + // This reduces contention in the users table. + if ($user->uid && REQUEST_TIME - $user->access > variable_get('session_write_interval', 180)) { + db_update('users') + ->fields(array( + 'access' => REQUEST_TIME + )) + ->condition('uid', $user->uid) + ->execute(); + } + + return TRUE; + } + catch (Exception $exception) { + require_once DRUPAL_ROOT . '/includes/errors.inc'; + // If we are displaying errors, then do so with no possibility of a further uncaught exception being thrown. + if (error_displayable()) { + print '

Uncaught exception thrown in session handler.

'; + print '

' . _drupal_render_exception_safe($exception) . '


'; + } + return FALSE; + } } /**