Skip to content

Commit

Permalink
Only include if the user is set
Browse files Browse the repository at this point in the history
  • Loading branch information
srtfisher committed Sep 11, 2020
1 parent f1e898c commit 94729c1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions inc/handler/class-post-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,14 @@ protected function write( array $record ): void {

// Capture the stack trace.
$record['extra']['backtrace'] = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace
$record['extra']['user'] = [
'ID' => $user->ID,
'user_login' => $user->user_login,
'user_email' => $user->user_email,
];

if ( $user ) {
$record['extra']['user'] = [
'ID' => $user->ID,
'user_login' => $user->user_login,
'user_email' => $user->user_email,
];
}

/**
* Filter the log record.
Expand Down

0 comments on commit 94729c1

Please sign in to comment.