Skip to content

Commit 0018ace

Browse files
fix: Hint "exception_ignore_args=0" if no arguments are available
The "contextDetails" mechanism iterates over available arguments and converts them into stringable reprentations. This broken when `zend.exception_ignore_args=1`, where the args value was not set at all, which resulted in an additonal Sentry exception of 'Warning: Undefined array key "args"'. This fix ommits this additoinal exceptgion and adds a hint to the initial sentry message.
1 parent 764afc9 commit 0018ace

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

Classes/Scope/Extra/VariablesFromStackProvider.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,22 @@ private function collectDataFromTrace(array $trace): Traversable
7777
if ($traceFunction !== $configFunction) {
7878
continue;
7979
}
80-
$values = [];
81-
foreach ($argumentPaths as $argumentPathName => $argumentPathLookup) {
82-
try {
83-
$values[$argumentPathName] = $this->representationSerialize(
84-
ObjectAccess::getPropertyPath($trace['args'], $argumentPathLookup)
85-
);
86-
} catch (Throwable $t) {
87-
$values[$argumentPathName] = '👻';
80+
81+
if (!isset($trace['args'])) {
82+
yield [$configFunction => ['💥' => 'Argument tracing is disabled. To enable, set `zend.exception_ignore_args=0` ⚙️']];
83+
} else {
84+
$values = [];
85+
foreach ($argumentPaths as $argumentPathName => $argumentPathLookup) {
86+
try {
87+
$values[$argumentPathName] = $this->representationSerialize(
88+
ObjectAccess::getPropertyPath($trace['args'], $argumentPathLookup)
89+
);
90+
} catch (Throwable $t) {
91+
$values[$argumentPathName] = '👻';
92+
}
8893
}
94+
yield [$configFunction => $values];
8995
}
90-
yield [$configFunction => $values];
9196
}
9297
}
9398

0 commit comments

Comments
 (0)