validation-bugsnag-email
This commit is contained in:
3
vendor/bugsnag/bugsnag-laravel/Gemfile
vendored
3
vendor/bugsnag/bugsnag-laravel/Gemfile
vendored
@@ -1,4 +1,3 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'bugsnag-maze-runner', git: 'https://github.com/bugsnag/maze-runner', tag: 'v3.6.0'
|
||||
gem "os", "~> 1.0"
|
||||
gem 'bugsnag-maze-runner', git: 'https://github.com/bugsnag/maze-runner', tag: 'v7.9.0'
|
||||
|
@@ -37,7 +37,7 @@ class BugsnagServiceProvider extends ServiceProvider
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '2.25.0';
|
||||
const VERSION = '2.25.1';
|
||||
|
||||
/**
|
||||
* Boot the service provider.
|
||||
@@ -180,6 +180,71 @@ class BugsnagServiceProvider extends ServiceProvider
|
||||
|
||||
$this->app->make(Tracker::class)->set($job);
|
||||
});
|
||||
|
||||
$this->setupQueueForLaravelVapor($queue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup queue events for Laravel Vapor.
|
||||
*
|
||||
* This is required because Laravel Vapor's queue system doesn't behave as
|
||||
* a daemonised queue worker (the 'looping' event never fires) but also
|
||||
* doesn't behave as a non-daemonised queue worker (our shutdown function
|
||||
* never fires).
|
||||
*
|
||||
* @param QueueManager $queue
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function setupQueueForLaravelVapor(QueueManager $queue)
|
||||
{
|
||||
// ensure we're running on vapor
|
||||
// this is how vapor-core does it, e.g.:
|
||||
// https://github.com/laravel/vapor-core/blob/61437221090850ba6e51dce15d0058d362654f9b/src/ConfiguresAssets.php#L16-L19
|
||||
if (!isset($_ENV['VAPOR_SSM_PATH'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
// used to keep track of if we're the ones disabling batch sending, so we
|
||||
// know if we need to re-enable it - if the user disables batch sending
|
||||
// then they don't want it enabled at all
|
||||
static $batchSendingWasDisabledByUs = false;
|
||||
|
||||
$queue->before(function () use (&$batchSendingWasDisabledByUs) {
|
||||
// clear breadcrumbs to stop them leaking between jobs
|
||||
$this->app->bugsnag->clearBreadcrumbs();
|
||||
|
||||
// only re-enable batch sending if we're the ones disabling it
|
||||
// this allows users to disable batch sending entirely
|
||||
if ($batchSendingWasDisabledByUs) {
|
||||
$this->app->bugsnag->setBatchSending(true);
|
||||
}
|
||||
});
|
||||
|
||||
$flush = function () use (&$batchSendingWasDisabledByUs) {
|
||||
// flush any events created in this job
|
||||
$this->app->bugsnag->flush();
|
||||
|
||||
// disable batch sending so any events after this get sent synchronously
|
||||
// this is important as exceptions are logged after the 'exceptionOccurred'
|
||||
// event fires, so the above flush is too early to send them
|
||||
// these exceptions would get sent after processing the next queued job,
|
||||
// but we'd still drop the last event when this queue worker stops running
|
||||
if ($this->app->bugsnag->isBatchSending()) {
|
||||
$this->app->bugsnag->setBatchSending(false);
|
||||
$batchSendingWasDisabledByUs = true;
|
||||
}
|
||||
};
|
||||
|
||||
// added in 5.2.41
|
||||
if (method_exists($queue, 'after')) {
|
||||
$queue->after($flush);
|
||||
}
|
||||
|
||||
// added in 5.2.41
|
||||
if (method_exists($queue, 'exceptionOccurred')) {
|
||||
$queue->exceptionOccurred($flush);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -65,6 +65,7 @@ final class BacktraceProcessor
|
||||
*/
|
||||
const LARAVEL_VENDOR_NAMESPACE = 'Illuminate\\';
|
||||
const LUMEN_VENDOR_NAMESPACE = 'Laravel\\';
|
||||
const COLLISION_VENDOR_NAMESPACE = 'NunoMaduro\\Collision\\';
|
||||
|
||||
/**
|
||||
* The current state; one of the self::STATE_ constants.
|
||||
@@ -132,7 +133,7 @@ final class BacktraceProcessor
|
||||
// if this class is a framework exception handler and the function
|
||||
// matches self::HANDLER_METHOD, we can move on to searching for
|
||||
// the caller
|
||||
if (($class === self::LARAVEL_HANDLER_CLASS || $class === self::LUMEN_HANDLER_CLASS)
|
||||
if ($this->isFrameworkExceptionHandler($class)
|
||||
&& isset($frame['function'])
|
||||
&& $frame['function'] === self::HANDLER_METHOD
|
||||
) {
|
||||
@@ -144,10 +145,7 @@ final class BacktraceProcessor
|
||||
case self::STATE_HANDLER_CALLER:
|
||||
// if this is an app exception handler or a framework class, we
|
||||
// can move on to determine if this was unhandled or not
|
||||
if ($class === self::LARAVEL_APP_EXCEPTION_HANDLER
|
||||
|| $class === self::LUMEN_APP_EXCEPTION_HANDLER
|
||||
|| $this->isVendor($class)
|
||||
) {
|
||||
if ($this->isAppExceptionHandler($class) || $this->isVendor($class)) {
|
||||
$this->state = self::STATE_IS_UNHANDLED;
|
||||
}
|
||||
|
||||
@@ -180,7 +178,47 @@ final class BacktraceProcessor
|
||||
*/
|
||||
private function isVendor($class)
|
||||
{
|
||||
return substr($class, 0, strlen(self::LARAVEL_VENDOR_NAMESPACE)) === self::LARAVEL_VENDOR_NAMESPACE
|
||||
|| substr($class, 0, strlen(self::LUMEN_VENDOR_NAMESPACE)) === self::LUMEN_VENDOR_NAMESPACE;
|
||||
return $this->isInNamespace($class, self::LARAVEL_VENDOR_NAMESPACE)
|
||||
|| $this->isInNamespace($class, self::LUMEN_VENDOR_NAMESPACE)
|
||||
|| $this->isInNamespace($class, self::COLLISION_VENDOR_NAMESPACE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given class is in the given namespace.
|
||||
*
|
||||
* @param string $class
|
||||
* @param string $namespace
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isInNamespace($class, $namespace)
|
||||
{
|
||||
return substr($class, 0, strlen($namespace)) === $namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the given class Laravel or Lumen's exception handler?
|
||||
*
|
||||
* @param string $class
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isFrameworkExceptionHandler($class)
|
||||
{
|
||||
return $class === self::LARAVEL_HANDLER_CLASS
|
||||
|| $class === self::LUMEN_HANDLER_CLASS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the given class an App's exception handler?
|
||||
*
|
||||
* @param string $class
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isAppExceptionHandler($class)
|
||||
{
|
||||
return $class === self::LARAVEL_APP_EXCEPTION_HANDLER
|
||||
|| $class === self::LUMEN_APP_EXCEPTION_HANDLER;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user