Problem/Motivation

From #2986294: Remove $context['user'] from LoggerChannel::log.

      try {
        if ($this->currentUser) {
          $context['uid'] = $this->currentUser->id();
        }
      }
      catch (\Exception $e) {
        // An exception might be thrown if the database connection is not
        // available or due to another unexpected reason. It is more important
        // to log the error that we already have so any additional exceptions
        // are ignored.
      }

As far as I can see there is never a situation anymore when getting the ID from the current_user service can throw an exception. This was resolved in #2753733: AccountProxy can do unnecessary user loads to get an ID

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

catch created an issue. See original summary.

th_tushar’s picture

Status: Active » Needs review
FileSize
1018 bytes

Removes unnecessary try/catch block.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 2: remove-unnecessary-try-catch-logger-2998727-2.patch, failed testing. View results

longwave’s picture

Status: Needs work » Reviewed & tested by the community
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 9f3ca2e and pushed to 8.7.x. Thanks!

  • catch committed 9f3ca2e on 8.7.x
    Issue #2998727 by th_tushar: Remove unnecessary try/catch from logger
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.