Skip to content

Commit

Permalink
Merge branch 'master' into releases/1.8.x
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	lib/Raven/Client.php
  • Loading branch information
stayallive committed Nov 9, 2017
2 parents b3a03c1 + e1001f8 commit 3e4bb14
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 29 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

- ...

## 1.8.1 (2017-11-09)

- Add setters for the serializers on the `Raven_Client` (#515)
- Avoid to capture `E_ERROR` in PHP 7+, because it's also a `Throwable` that gets captured and duplicates the error (#514)

## 1.8.0 (2017-10-29)

- Use namespaced classes in test for PHPUnit (#506)
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,28 +98,28 @@ Tagging a Release
2. Create a new branch for the minor version (if not present):

```
$ git checkout -b releases/1.7.x
$ git checkout -b releases/1.9.x
```

3. Update the hardcoded version tag in ``Client.php``:

```
class Raven_Client
{
const VERSION = '1.7.0';
const VERSION = '1.9.0';
}
```

4. Commit the change:

```
$ git commit -a -m "1.7.0"
$ git commit -a -m "1.9.0"
```

5. Tag the branch:

```
git tag 1.7.0
git tag 1.9.0
```

6. Push the tag:
Expand All @@ -137,15 +137,15 @@ git checkout master
8. Add the next minor release to the ``CHANGES`` file:

```
## 1.8.0 (unreleased)
## 1.10.0 (unreleased)
```

9. Update the version in ``Client.php``:

```
class Raven_Client
{
const VERSION = '1.8.x-dev';
const VERSION = '1.10.x-dev';
}
```

Expand All @@ -154,7 +154,7 @@ class Raven_Client
```
"extra": {
"branch-alias": {
"dev-master": "1.8.x-dev"
"dev-master": "1.10.x-dev"
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.8.x-dev"
"dev-master": "1.9.x-dev"
}
}
}
36 changes: 29 additions & 7 deletions lib/Raven/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class Raven_Client
{
const VERSION = '1.8.0';
const VERSION = '1.8.1';

const PROTOCOL = '6';

Expand Down Expand Up @@ -44,7 +44,13 @@ class Raven_Client
protected $error_handler;
protected $error_types;

/**
* @var Raven_Serializer
*/
protected $serializer;
/**
* @var Raven_ReprSerializer
*/
protected $reprSerializer;

/**
Expand Down Expand Up @@ -561,15 +567,15 @@ public function captureMessage($message, $params = array(), $data = array(),
/**
* Log an exception to sentry
*
* @param Exception $exception The Exception object.
* @param array $data Additional attributes to pass with this event (see Sentry docs).
* @param mixed $logger
* @param mixed $vars
* @param \Throwable|\Exception $exception The Throwable/Exception object.
* @param array $data Additional attributes to pass with this event (see Sentry docs).
* @param mixed $logger
* @param mixed $vars
* @return string|null
*/
public function captureException($exception, $data = null, $logger = null, $vars = null)
{
$has_chained_exceptions = version_compare(PHP_VERSION, '5.3.0', '>=');
$has_chained_exceptions = PHP_VERSION_ID >= 50300;

if (in_array(get_class($exception), $this->exclude)) {
return null;
Expand Down Expand Up @@ -1328,7 +1334,7 @@ public function translateSeverity($severity)
case E_STRICT: return Raven_Client::INFO;
case E_RECOVERABLE_ERROR: return Raven_Client::ERROR;
}
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
if (PHP_VERSION_ID >= 50300) {
switch ($severity) {
case E_DEPRECATED: return Raven_Client::WARN;
case E_USER_DEPRECATED: return Raven_Client::WARN;
Expand Down Expand Up @@ -1447,4 +1453,20 @@ public function close_curl_resource()
$this->_curl_instance = null;
}
}

/**
* @param Raven_Serializer $serializer
*/
public function setSerializer(Raven_Serializer $serializer)
{
$this->serializer = $serializer;
}

/**
* @param Raven_ReprSerializer $reprSerializer
*/
public function setReprSerializer(Raven_ReprSerializer $reprSerializer)
{
$this->reprSerializer = $reprSerializer;
}
}
4 changes: 2 additions & 2 deletions lib/Raven/Compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ public static function _hash_hmac($algo, $data, $key, $raw_output = false)
public static function json_encode($value, $options = 0, $depth = 512)
{
if (function_exists('json_encode')) {
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
if (PHP_VERSION_ID < 50300) {
return json_encode($value);
} elseif (version_compare(PHP_VERSION, '5.5.0', '<')) {
} elseif (PHP_VERSION_ID < 50500) {
return json_encode($value, $options);
} else {
return json_encode($value, $options, $depth);
Expand Down
2 changes: 1 addition & 1 deletion lib/Raven/CurlHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct($options, $join_timeout = 5)
$this->options = $options;
$this->multi_handle = curl_multi_init();
$this->requests = array();
$this->join_timeout = 5;
$this->join_timeout = $join_timeout;

register_shutdown_function(array($this, 'join'));
}
Expand Down
7 changes: 7 additions & 0 deletions lib/Raven/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ 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
23 changes: 14 additions & 9 deletions test/Raven/Tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ public function testCaptureExceptionSetsInterfaces()
*/
public function testCaptureExceptionChainedException()
{
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
if (PHP_VERSION_ID < 50300) {
$this->markTestSkipped('PHP 5.3 required for chained exceptions.');
}

Expand All @@ -610,7 +610,7 @@ public function testCaptureExceptionChainedException()
*/
public function testCaptureExceptionDifferentLevelsInChainedExceptionsBug()
{
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
if (PHP_VERSION_ID < 50300) {
$this->markTestSkipped('PHP 5.3 required for chained exceptions.');
}

Expand Down Expand Up @@ -1437,6 +1437,8 @@ public function testUuid4()
* @covers Raven_Client::getLastEventID
* @covers Raven_Client::get_extra_data
* @covers Raven_Client::setProcessors
* @covers Raven_Client::setSerializer
* @covers Raven_Client::setReprSerializer
* @covers Raven_Client::getLastSentryError
* @covers Raven_Client::getShutdownFunctionHasBeenSet
*/
Expand All @@ -1447,6 +1449,9 @@ public function testGettersAndSetters()
$property_method__convert_path->setAccessible(true);
$callable = array($this, 'stabClosureVoid');

$serializer = $this->getMockBuilder('Raven_Serializer')->getMock();
$reprSerializer = $this->getMockBuilder('Raven_ReprSerializer')->getMock();

$data = array(
array('environment', null, 'value', ),
array('environment', null, null, ),
Expand Down Expand Up @@ -1476,6 +1481,8 @@ public function testGettersAndSetters()
array('extra_data', '_extra_data', array('key' => 'value'), ),
array('processors', 'processors', array(), ),
array('processors', 'processors', array('key' => 'value'), ),
array('serializer', 'Serializer', $serializer, ),
array('reprSerializer', 'ReprSerializer', $reprSerializer, ),
array('_shutdown_function_has_been_set', null, true),
array('_shutdown_function_has_been_set', null, false),
);
Expand Down Expand Up @@ -1600,7 +1607,7 @@ public function testTranslateSeverity()
$predefined = array(E_ERROR, E_WARNING, E_PARSE, E_NOTICE, E_CORE_ERROR, E_CORE_WARNING,
E_COMPILE_ERROR, E_COMPILE_WARNING, E_USER_ERROR, E_USER_WARNING,
E_USER_NOTICE, E_STRICT, E_RECOVERABLE_ERROR, );
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
if (PHP_VERSION_ID >= 50300) {
$predefined[] = E_DEPRECATED;
$predefined[] = E_USER_DEPRECATED;
}
Expand Down Expand Up @@ -1769,7 +1776,7 @@ public function testEncodeTooDepth()
$data_broken = array($data_broken);
}
$value = $client->encode($data_broken);
if (!function_exists('json_encode') or version_compare(PHP_VERSION, '5.5.0', '>=')) {
if (!function_exists('json_encode') or PHP_VERSION_ID >= 50500) {
$this->assertFalse($value, 'Broken data encoded successfully with '.
(function_exists('json_encode') ? 'native method' : 'Raven_Compat::_json_encode'));
} else {
Expand Down Expand Up @@ -1817,11 +1824,9 @@ public function testRegisterDefaultBreadcrumbHandlers()
$debug_backtrace = $this->_debug_backtrace;
set_error_handler($previous, E_ALL);
$this->assertTrue($u);
if (isset($debug_backtrace[1]['function']) and ($debug_backtrace[1]['function'] == 'call_user_func')
and version_compare(PHP_VERSION, '7.0', '>=')
) {
if (isset($debug_backtrace[1]['function']) and ($debug_backtrace[1]['function'] == 'call_user_func') and PHP_VERSION_ID >= 70000) {
$offset = 2;
} elseif (version_compare(PHP_VERSION, '7.0', '>=')) {
} elseif (PHP_VERSION_ID >= 70000) {
$offset = 1;
} else {
$offset = 2;
Expand Down Expand Up @@ -2048,7 +2053,7 @@ public function testGet_user_data_step1()
*/
public function testGet_user_data_step2()
{
if (version_compare(PHP_VERSION, '7.1.999', '>')) {
if (PHP_VERSION_ID >= 70200) {
/**
* @doc https://3v4l.org/OVbja
* @doc https://3v4l.org/uT00O
Expand Down
2 changes: 1 addition & 1 deletion test/Raven/Tests/ErrorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function testShouldCaptureFatalErrorBehavior()
->getMock();
$handler = new Raven_ErrorHandler($client);

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

$this->assertEquals($handler->shouldCaptureFatalError(E_WARNING), false);
}
Expand Down
2 changes: 1 addition & 1 deletion test/Raven/Tests/StacktraceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function testDoesFixFrameInfo()
// just grab the last few frames
$frames = array_slice($frames, -6);
$skip_call_user_func_fix = false;
if (version_compare(PHP_VERSION, '7.0', '>=')) {
if (PHP_VERSION_ID >= 70000) {
$skip_call_user_func_fix = true;
foreach ($frames as &$frame) {
if (isset($frame['function']) and ($frame['function'] == 'call_user_func')) {
Expand Down

0 comments on commit 3e4bb14

Please sign in to comment.