Skip to content

Commit 12d0f96

Browse files
authored
Prepare release 4.3.0
2 parents 4174898 + f2290df commit 12d0f96

20 files changed

+144
-6
lines changed

.github/workflows/tests.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,20 @@ jobs:
9292
missing-optional-packages-tests:
9393
name: Tests without optional packages
9494
runs-on: ubuntu-latest
95+
env:
96+
SYMFONY_REQUIRE: ${{ matrix.symfony-version }}
9597
strategy:
9698
fail-fast: false
9799
matrix:
98100
include:
99101
- php: '7.2'
100102
dependencies: lowest
103+
symfony-version: 3.4.*
101104
- php: '7.4'
102105
dependencies: highest
103106
- php: '8.0'
104107
dependencies: lowest
108+
symfony-version: 4.4.*
105109
- php: '8.1'
106110
dependencies: highest
107111

@@ -113,7 +117,8 @@ jobs:
113117
uses: shivammathur/setup-php@v2
114118
with:
115119
php-version: ${{ matrix.php }}
116-
coverage: xdebug
120+
coverage: pcov
121+
tools: flex
117122

118123
- name: Setup Problem Matchers for PHPUnit
119124
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
## Unreleased
44

5+
## 4.3.0 (2022-05-30)
56
- Fix compatibility issue with Symfony >= 6.1.0 (#635)
7+
- Add `TracingDriverConnectionInterface::getNativeConnection()` method to get the original driver connection (#597)
8+
- Add `options.http_timeout` and `options.http_connect_timeout` configuration options (#593)
69

710
## 4.2.10 (2022-05-17)
811

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"php": "^7.2||^8.0",
2727
"jean85/pretty-package-versions": "^1.5 || ^2.0",
2828
"php-http/discovery": "^1.11",
29-
"sentry/sdk": "^3.1",
29+
"sentry/sdk": "^3.2",
3030
"symfony/cache-contracts": "^1.1||^2.4||^3.0",
3131
"symfony/config": "^3.4.44||^4.4.20||^5.0.11||^6.0",
3232
"symfony/console": "^3.4.44||^4.4.20||^5.0.11||^6.0",
@@ -97,7 +97,7 @@
9797
},
9898
"extra": {
9999
"branch-alias": {
100-
"dev-master": "4.2.x-dev",
100+
"dev-master": "4.3.x-dev",
101101
"releases/3.2.x": "3.2.x-dev",
102102
"releases/2.x": "2.x-dev",
103103
"releases/1.x": "1.x-dev"

phpstan-baseline.neon

+1-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ parameters:
436436
path: tests/Tracing/Doctrine/DBAL/TracingServerInfoAwareDriverConnectionTest.php
437437

438438
-
439-
message: "#^Trying to mock an undefined method requiresQueryForServerVersion\\(\\) on class Sentry\\\\SentryBundle\\\\Tests\\\\Tracing\\\\Doctrine\\\\DBAL\\\\ServerInfoAwareConnectionStub\\.$#"
439+
message: "#^Trying to mock an undefined method requiresQueryForServerVersion\\(\\) on class Sentry\\\\SentryBundle\\\\Tests\\\\Tracing\\\\Doctrine\\\\DBAL\\\\Fixture\\\\ServerInfoAwareConnectionStub\\.$#"
440440
count: 1
441441
path: tests/Tracing/Doctrine/DBAL/TracingServerInfoAwareDriverConnectionTest.php
442442

src/DependencyInjection/Configuration.php

+8
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ public function getConfigTreeBuilder(): TreeBuilder
116116
->booleanNode('send_default_pii')->end()
117117
->integerNode('max_value_length')->min(0)->end()
118118
->scalarNode('http_proxy')->end()
119+
->integerNode('http_connect_timeout')
120+
->min(0)
121+
->info('The maximum number of seconds to wait while trying to connect to a server. It works only when using the default transport.')
122+
->end()
123+
->integerNode('http_timeout')
124+
->min(0)
125+
->info('The maximum execution time for the request+response as a whole. It works only when using the default transport.')
126+
->end()
119127
->booleanNode('capture_silenced_errors')->end()
120128
->enumNode('max_request_body_size')
121129
->values([

src/Resources/config/schema/sentry-1.0.xsd

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
<xsd:attribute name="send-default-pii" type="xsd:boolean" />
5050
<xsd:attribute name="max-value-length" type="xsd:integer" />
5151
<xsd:attribute name="http-proxy" type="xsd:string" />
52+
<xsd:attribute name="http-timeout" type="xsd:integer" />
53+
<xsd:attribute name="http-connect-timeout" type="xsd:integer" />
5254
<xsd:attribute name="capture-silenced-errors" type="xsd:boolean" />
5355
<xsd:attribute name="max-request-body-size" type="max-request-body-size" />
5456
</xsd:complexType>

src/Tracing/Doctrine/DBAL/TracingDriverConnection.php

+14
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,20 @@ public function rollBack(): bool
168168
});
169169
}
170170

171+
/**
172+
* {@inheritdoc}
173+
*
174+
* @return resource|object
175+
*/
176+
public function getNativeConnection()
177+
{
178+
if (!method_exists($this->decoratedConnection, 'getNativeConnection')) {
179+
throw new \BadMethodCallException(sprintf('The connection "%s" does not support accessing the native connection.', \get_class($this->decoratedConnection)));
180+
}
181+
182+
return $this->decoratedConnection->getNativeConnection();
183+
}
184+
171185
/**
172186
* {@inheritdoc}
173187
*/

src/Tracing/Doctrine/DBAL/TracingDriverConnectionInterface.php

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
use Doctrine\DBAL\Driver\Connection;
88

9+
/**
10+
* @method resource|object getNativeConnection()
11+
*/
912
interface TracingDriverConnectionInterface extends Connection
1013
{
1114
public function getWrappedConnection(): Connection;

src/Tracing/Doctrine/DBAL/TracingServerInfoAwareDriverConnection.php

+14
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,20 @@ public function getServerVersion(): string
115115
return $wrappedConnection->getServerVersion();
116116
}
117117

118+
/**
119+
* {@inheritdoc}
120+
*
121+
* @return resource|object
122+
*/
123+
public function getNativeConnection()
124+
{
125+
if (!method_exists($this->decoratedConnection, 'getNativeConnection')) {
126+
throw new \BadMethodCallException(sprintf('The connection "%s" does not support accessing the native connection.', \get_class($this->decoratedConnection)));
127+
}
128+
129+
return $this->decoratedConnection->getNativeConnection();
130+
}
131+
118132
/**
119133
* {@inheritdoc}
120134
*/

tests/DependencyInjection/Fixtures/php/full.php

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
'send_default_pii' => true,
3737
'max_value_length' => 255,
3838
'http_proxy' => 'proxy.example.com:8080',
39+
'http_timeout' => 10,
40+
'http_connect_timeout' => 15,
3941
'capture_silenced_errors' => true,
4042
'max_request_body_size' => 'none',
4143
'class_serializers' => ['App\\FooClass' => 'App\\Sentry\\Serializer\\FooClassSerializer'],

tests/DependencyInjection/Fixtures/xml/full.xml

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
send-default-pii="true"
3131
max-value-length="255"
3232
http-proxy="proxy.example.com:8080"
33+
http-timeout="10"
34+
http-connect-timeout="15"
3335
capture-silenced-errors="true"
3436
max-request-body-size="none"
3537
>

tests/DependencyInjection/Fixtures/yml/full.yml

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ sentry:
3232
send_default_pii: true
3333
max_value_length: 255
3434
http_proxy: proxy.example.com:8080
35+
http_timeout: 10
36+
http_connect_timeout: 15
3537
capture_silenced_errors: true
3638
max_request_body_size: 'none'
3739
class_serializers:

tests/DependencyInjection/SentryExtensionTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ public function testClientIsCreatedFromOptions(): void
219219
'send_default_pii' => true,
220220
'max_value_length' => 255,
221221
'http_proxy' => 'proxy.example.com:8080',
222+
'http_timeout' => 10,
223+
'http_connect_timeout' => 15,
222224
'capture_silenced_errors' => true,
223225
'max_request_body_size' => 'none',
224226
'class_serializers' => [

tests/End2End/App/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ sentry:
22
tracing:
33
enabled: true
44
options:
5-
capture_silenced_errors: true
5+
capture_silenced_errors: false
66
error_types: E_ALL & ~E_USER_DEPRECATED
77
traces_sample_rate: 0
88

tests/End2End/End2EndTest.php

+9
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,15 @@ public function testGetFatal(): void
162162
public function testNotice(): void
163163
{
164164
$client = static::createClient();
165+
166+
/** @var HubInterface $hub */
167+
$hub = $client->getContainer()->get('test.hub');
168+
$sentryClient = $hub->getClient();
169+
170+
$this->assertNotNull($sentryClient);
171+
172+
$sentryClient->getOptions()->setCaptureSilencedErrors(true);
173+
165174
$client->request('GET', '/notice');
166175

167176
$response = $client->getResponse();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Sentry\SentryBundle\Tests\Tracing\Doctrine\DBAL\Fixture;
6+
7+
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnectionInterface;
8+
9+
interface NativeDriverConnectionInterfaceStub extends TracingDriverConnectionInterface
10+
{
11+
/**
12+
* @return object|resource
13+
*/
14+
public function getNativeConnection();
15+
}

tests/Tracing/Doctrine/DBAL/ServerInfoAwareConnectionStub.php tests/Tracing/Doctrine/DBAL/Fixture/ServerInfoAwareConnectionStub.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Sentry\SentryBundle\Tests\Tracing\Doctrine\DBAL;
5+
namespace Sentry\SentryBundle\Tests\Tracing\Doctrine\DBAL\Fixture;
66

77
use Doctrine\DBAL\Driver\Connection;
88
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;

tests/Tracing/Doctrine/DBAL/TracingDriverConnectionFactoryTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Doctrine\DBAL\Platforms\AbstractPlatform;
99
use PHPUnit\Framework\MockObject\MockObject;
1010
use Sentry\SentryBundle\Tests\DoctrineTestCase;
11+
use Sentry\SentryBundle\Tests\Tracing\Doctrine\DBAL\Fixture\ServerInfoAwareConnectionStub;
1112
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnection;
1213
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnectionFactory;
1314
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingServerInfoAwareDriverConnection;

tests/Tracing/Doctrine/DBAL/TracingDriverConnectionTest.php

+28
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
use Doctrine\DBAL\ParameterType;
1111
use PHPUnit\Framework\MockObject\MockObject;
1212
use Sentry\SentryBundle\Tests\DoctrineTestCase;
13+
use Sentry\SentryBundle\Tests\Tracing\Doctrine\DBAL\Fixture\NativeDriverConnectionInterfaceStub;
1314
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnection;
15+
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnectionInterface;
1416
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingStatement;
1517
use Sentry\State\HubInterface;
1618
use Sentry\Tracing\Transaction;
@@ -417,6 +419,32 @@ public function testGetWrappedConnection(): void
417419
$this->assertSame($this->decoratedConnection, $connection->getWrappedConnection());
418420
}
419421

422+
public function testGetNativeConnection(): void
423+
{
424+
$nativeConnection = new class() {
425+
};
426+
427+
$decoratedConnection = $this->createMock(NativeDriverConnectionInterfaceStub::class);
428+
$decoratedConnection->expects($this->once())
429+
->method('getNativeConnection')
430+
->willReturn($nativeConnection);
431+
432+
$connection = new TracingDriverConnection($this->hub, $decoratedConnection, 'foo_platform', []);
433+
434+
$this->assertSame($nativeConnection, $connection->getNativeConnection());
435+
}
436+
437+
public function testGetNativeConnectionThrowsExceptionIfDecoratedConnectionDoesNotImplementMethod(): void
438+
{
439+
$decoratedConnection = $this->createMock(TracingDriverConnectionInterface::class);
440+
$connection = new TracingDriverConnection($this->hub, $decoratedConnection, 'foo_platform', []);
441+
442+
$this->expectException(\BadMethodCallException::class);
443+
$this->expectExceptionMessageMatches('/The connection ".*?" does not support accessing the native connection\./');
444+
445+
$connection->getNativeConnection();
446+
}
447+
420448
/**
421449
* @return \Generator<mixed>
422450
*/

tests/Tracing/Doctrine/DBAL/TracingServerInfoAwareDriverConnectionTest.php

+28
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use Doctrine\DBAL\ParameterType;
1111
use PHPUnit\Framework\MockObject\MockObject;
1212
use Sentry\SentryBundle\Tests\DoctrineTestCase;
13+
use Sentry\SentryBundle\Tests\Tracing\Doctrine\DBAL\Fixture\NativeDriverConnectionInterfaceStub;
14+
use Sentry\SentryBundle\Tests\Tracing\Doctrine\DBAL\Fixture\ServerInfoAwareConnectionStub;
1315
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnectionInterface;
1416
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingServerInfoAwareDriverConnection;
1517

@@ -256,4 +258,30 @@ public function testGetWrappedConnection(): void
256258

257259
$this->assertSame($wrappedConnection, $this->connection->getWrappedConnection());
258260
}
261+
262+
public function testGetNativeConnection(): void
263+
{
264+
$nativeConnection = new class() {
265+
};
266+
267+
$decoratedConnection = $this->createMock(NativeDriverConnectionInterfaceStub::class);
268+
$decoratedConnection->expects($this->once())
269+
->method('getNativeConnection')
270+
->willReturn($nativeConnection);
271+
272+
$connection = new TracingServerInfoAwareDriverConnection($decoratedConnection);
273+
274+
$this->assertSame($nativeConnection, $connection->getNativeConnection());
275+
}
276+
277+
public function testGetNativeConnectionThrowsExceptionIfDecoratedConnectionDoesNotImplementMethod(): void
278+
{
279+
$decoratedConnection = $this->createMock(TracingDriverConnectionInterface::class);
280+
$connection = new TracingServerInfoAwareDriverConnection($decoratedConnection);
281+
282+
$this->expectException(\BadMethodCallException::class);
283+
$this->expectExceptionMessageMatches('/The connection ".*?" does not support accessing the native connection\./');
284+
285+
$connection->getNativeConnection();
286+
}
259287
}

0 commit comments

Comments
 (0)