Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#2 | remove-unnecessary-try-catch-logger-2998727-2.patch | 1018 bytes | th_tushar |
Comments
Comment #2
th_tushar CreditAttribution: th_tushar as a volunteer commentedRemoves unnecessary try/catch block.
Comment #3
longwaveComment #5
longwaveComment #6
catchCommitted 9f3ca2e and pushed to 8.7.x. Thanks!