Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide method to register async shutdown function #613

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions lib/Raven/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,8 @@ public function install()
$this->error_handler->registerErrorHandler();
$this->error_handler->registerShutdownFunction();

if ($this->_curl_handler) {
$this->_curl_handler->registerShutdownFunction();
}
// Register final shutdown function to send fatal error via curl async.
$this->registerShutdownFunction();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove the if here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not necessary, but the idea here was that this would be the suggested way to register shutdown function - given that _curl_handler is protected, this line is useful for anyone who is writing custom code and wants to reproduce the functionality of the install() method.


return $this;
}
Expand Down Expand Up @@ -742,12 +741,10 @@ protected function registerDefaultBreadcrumbHandlers()
$handler->install();
}

protected function registerShutdownFunction()
public function registerShutdownFunction()
{
if (!$this->_shutdown_function_has_been_set) {
$this->_shutdown_function_has_been_set = true;
register_shutdown_function(array($this, 'onShutdown'));
}
$this->_shutdown_function_has_been_set = true;
register_shutdown_function(array($this, 'onShutdown'));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the if removed here? If we can prevent it we should not add all the shutdown handlers...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using curl async, we need to register the shutdown function a second time, so that it runs after the fatal error handler.

}

/**
Expand Down