Skip to content

Commit 32bf2d7

Browse files
#73: reproduce changes from PR 75 for the laravel-5.5 branch
1 parent 44ff13f commit 32bf2d7

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/RollbarLogHandler.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,24 @@ protected function addContext(array $context = [])
104104
if (isset($context['person']) and is_array($context['person'])) {
105105
$person = $context['person'];
106106
unset($context['person']);
107-
} else {
108-
if (isset($config['person_fn']) && is_callable($config['person_fn'])) {
109-
$data = @call_user_func($config['person_fn']);
110-
if (isset($data['id'])) {
111-
$person = call_user_func($config['person_fn']);
107+
} elseif (isset($config['person_fn']) && is_callable($config['person_fn'])) {
108+
$data = @call_user_func($config['person_fn']);
109+
if (! empty($data)) {
110+
if (is_object($data)) {
111+
if (isset($data->id)) {
112+
$person['id'] = $data->id;
113+
if (isset($data->username)) {
114+
$person['username'] = $data->username;
115+
}
116+
if (isset($data->email)) {
117+
$person['email'] = $data->email;
118+
}
119+
}
120+
} elseif (is_array($data) && isset($data['id'])) {
121+
$person = $data;
112122
}
113123
}
124+
unset($data);
114125
}
115126

116127
// Add user session information.

0 commit comments

Comments
 (0)