Skip to content

Commit

Permalink
Try to fix #552 allowing all fatals to be captured; add regression PH…
Browse files Browse the repository at this point in the history
…PT test (#571)
  • Loading branch information
Jean85 authored Mar 20, 2018
1 parent ec5a234 commit 047f0d3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
7 changes: 0 additions & 7 deletions lib/Raven/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,6 @@ public function handleFatalError()

public function shouldCaptureFatalError($type)
{
// Do not capture E_ERROR since those can be caught by userland since PHP 7.0
// E_ERROR should already be handled by the exception handler
// This prevents duplicated exceptions in PHP 7.0+
if (PHP_VERSION_ID >= 70000 && $type === E_ERROR) {
return false;
}

return $type & $this->fatal_error_types;
}

Expand Down
2 changes: 0 additions & 2 deletions test/Raven/Tests/ErrorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,6 @@ public function testShouldCaptureFatalErrorBehavior()
->getMock();
$handler = new Raven_ErrorHandler($client);

$this->assertEquals($handler->shouldCaptureFatalError(E_ERROR), PHP_VERSION_ID < 70000);

$this->assertEquals($handler->shouldCaptureFatalError(E_WARNING), false);
}

Expand Down
30 changes: 30 additions & 0 deletions test/Raven/phpt/fatal_reported_twice_regression.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
Test that, when handling a fatal, we report it once and only once
--FILE--
<?php

$vendor = __DIR__;
while (!file_exists($vendor.'/vendor')) {
$vendor = dirname($vendor);
}
require $vendor.'/test/bootstrap.php';

error_reporting(E_ALL);
$client = new \Raven_Client();
set_error_handler(function () use ($client) {
echo 'Previous error handler is called' . PHP_EOL;
echo 'Error is ' . ($client->getLastEventID() !== null ? 'reported correctly' : 'NOT reported');
});

set_exception_handler(function () {
echo 'This should not be called';
});

$client->install();

require 'inexistent_file.php';
?>
--EXPECTF--
Previous error handler is called
Error is reported correctly
Fatal error: %a

0 comments on commit 047f0d3

Please sign in to comment.