Skip to content

Commit 21eb1cb

Browse files
authored
[Fix] v1.2.3 Accessing currentRequest without validating that it exists (#6)
* check if session exists before accessing it * added return value * this is starting to get annoying
1 parent 2b1b5d7 commit 21eb1cb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/ExceptionEnricher/Processor/ExceptionEnricherProcessor.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ public function __invoke(array $record): array
3939
if ($this->requestStack->getCurrentRequest()->headers) {
4040
$record['extra']['request_user_agent'] = $this->requestStack->getCurrentRequest()->headers->get('User-Agent');
4141
}
42+
43+
if ($this->requestStack->getCurrentRequest()->hasSession() && $this->requestStack->getSession()->getId()) {
44+
$record['extra']['session_id'] = $this->requestStack->getSession()->getId();
45+
}
4246
}
4347

4448
if ($this->requestStack->getMainRequest()) {
4549
$record['extra']['request_ip'] = $this->requestStack->getMainRequest()->getClientIp();
4650
}
47-
48-
if ($this->requestStack->getCurrentRequest()->hasSession() && $this->requestStack->getSession()->getId()) {
49-
$record['extra']['session_id'] = $this->requestStack->getSession()->getId();
50-
}
5151
}
5252

5353
if ($this->tokenStorage && $this->tokenStorage->getToken()) {

0 commit comments

Comments
 (0)