Skip to content

Commit

Permalink
Apply fix for #391: culprit was bad autoloading during fatal handling…
Browse files Browse the repository at this point in the history
… under PHP > 7
  • Loading branch information
Jean85 committed Mar 21, 2018
1 parent 89d4b31 commit 1a2022b
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions lib/Raven/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@ public function __construct($options_or_dsn = null, $options = array())
if (Raven_Util::get($options, 'install_shutdown_handler', true)) {
$this->registerShutdownFunction();
}

// manually trigger autoloading, as it cannot be done during error handling in some edge cases due to PHP (see #60149)
if (!class_exists('Raven_Stacktrace')) {
// @codeCoverageIgnoreStart
spl_autoload_call('Raven_Stacktrace');
// @codeCoverageIgnoreEnd
}
}

public function __destruct()
Expand Down Expand Up @@ -630,13 +637,6 @@ public function captureException($exception, $data = null, $logger = null, $vars

array_unshift($trace, $frame_where_exception_thrown);

// manually trigger autoloading, as it's not done in some edge cases due to PHP bugs (see #60149)
if (!class_exists('Raven_Stacktrace')) {
// @codeCoverageIgnoreStart
spl_autoload_call('Raven_Stacktrace');
// @codeCoverageIgnoreEnd
}

$exc_data['stacktrace'] = array(
'frames' => Raven_Stacktrace::get_stack_info(
$trace, $this->trace, $vars, $this->message_limit, $this->prefixes,
Expand Down Expand Up @@ -900,22 +900,13 @@ public function capture($data, $stack = null, $vars = null)
array_shift($stack);
}

if (!empty($stack)) {
// manually trigger autoloading, as it's not done in some edge cases due to PHP bugs (see #60149)
if (!class_exists('Raven_Stacktrace')) {
// @codeCoverageIgnoreStart
spl_autoload_call('Raven_Stacktrace');
// @codeCoverageIgnoreEnd
}

if (!isset($data['stacktrace']) && !isset($data['exception'])) {
$data['stacktrace'] = array(
'frames' => Raven_Stacktrace::get_stack_info(
$stack, $this->trace, $vars, $this->message_limit, $this->prefixes,
$this->app_path, $this->excluded_app_paths, $this->serializer, $this->reprSerializer
),
);
}
if (! empty($stack) && ! isset($data['stacktrace']) && ! isset($data['exception'])) {
$data['stacktrace'] = array(
'frames' => Raven_Stacktrace::get_stack_info(
$stack, $this->trace, $vars, $this->message_limit, $this->prefixes,
$this->app_path, $this->excluded_app_paths, $this->serializer, $this->reprSerializer
),
);
}

$this->sanitize($data);
Expand Down

0 comments on commit 1a2022b

Please sign in to comment.