Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295277

Remove try...catch from SessionHandler::write

$
0
0

Problem/Motivation

Quoting from SessionHandler::write():

  public function write($sid, $value) {
    // The exception handler is not active at this point, so we need to do it
    // manually.
    try {
      [...]
      return TRUE;
    }
    catch (\Exception $exception) {
      require_once DRUPAL_ROOT . '/core/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 '<h1>Uncaught exception thrown in session handler.</h1>';
        print '<p>' . Error::renderExceptionSafe($exception) . '</p><hr />';
      }
      return FALSE;
    }
  }

The comments are out of date, the exception handler is in place way before the session subsystem gets initialized. In addition it is preferable to let an exception fall through to the exception handler instead of attempting to render it into the (already finished) output because:

  1. The exception handler will try to properly log the exception
  2. The output might be of a different type than HTML

Proposed resolution

Remove the try...catch.

Remaining tasks

Review.

User interface changes

None.

API changes

None.

Data model changes

None.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue categoryBug because the custom try...catch possibly clobbers non-HTML output and suppresses logging
Issue priorityNormal

Viewing all articles
Browse latest Browse all 295277

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>