Skip to content

Commit

Permalink
Prepare release 4.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ste93cry authored May 30, 2022
2 parents 4174898 + f2290df commit 12d0f96
Show file tree
Hide file tree
Showing 20 changed files with 144 additions and 6 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,20 @@ jobs:
missing-optional-packages-tests:
name: Tests without optional packages
runs-on: ubuntu-latest
env:
SYMFONY_REQUIRE: ${{ matrix.symfony-version }}
strategy:
fail-fast: false
matrix:
include:
- php: '7.2'
dependencies: lowest
symfony-version: 3.4.*
- php: '7.4'
dependencies: highest
- php: '8.0'
dependencies: lowest
symfony-version: 4.4.*
- php: '8.1'
dependencies: highest

Expand All @@ -113,7 +117,8 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
coverage: pcov
tools: flex

- name: Setup Problem Matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

## Unreleased

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

## 4.2.10 (2022-05-17)

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"php": "^7.2||^8.0",
"jean85/pretty-package-versions": "^1.5 || ^2.0",
"php-http/discovery": "^1.11",
"sentry/sdk": "^3.1",
"sentry/sdk": "^3.2",
"symfony/cache-contracts": "^1.1||^2.4||^3.0",
"symfony/config": "^3.4.44||^4.4.20||^5.0.11||^6.0",
"symfony/console": "^3.4.44||^4.4.20||^5.0.11||^6.0",
Expand Down Expand Up @@ -97,7 +97,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "4.2.x-dev",
"dev-master": "4.3.x-dev",
"releases/3.2.x": "3.2.x-dev",
"releases/2.x": "2.x-dev",
"releases/1.x": "1.x-dev"
Expand Down
2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ parameters:
path: tests/Tracing/Doctrine/DBAL/TracingServerInfoAwareDriverConnectionTest.php

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

Expand Down
8 changes: 8 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ public function getConfigTreeBuilder(): TreeBuilder
->booleanNode('send_default_pii')->end()
->integerNode('max_value_length')->min(0)->end()
->scalarNode('http_proxy')->end()
->integerNode('http_connect_timeout')
->min(0)
->info('The maximum number of seconds to wait while trying to connect to a server. It works only when using the default transport.')
->end()
->integerNode('http_timeout')
->min(0)
->info('The maximum execution time for the request+response as a whole. It works only when using the default transport.')
->end()
->booleanNode('capture_silenced_errors')->end()
->enumNode('max_request_body_size')
->values([
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/config/schema/sentry-1.0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
<xsd:attribute name="send-default-pii" type="xsd:boolean" />
<xsd:attribute name="max-value-length" type="xsd:integer" />
<xsd:attribute name="http-proxy" type="xsd:string" />
<xsd:attribute name="http-timeout" type="xsd:integer" />
<xsd:attribute name="http-connect-timeout" type="xsd:integer" />
<xsd:attribute name="capture-silenced-errors" type="xsd:boolean" />
<xsd:attribute name="max-request-body-size" type="max-request-body-size" />
</xsd:complexType>
Expand Down
14 changes: 14 additions & 0 deletions src/Tracing/Doctrine/DBAL/TracingDriverConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,20 @@ public function rollBack(): bool
});
}

/**
* {@inheritdoc}
*
* @return resource|object
*/
public function getNativeConnection()
{
if (!method_exists($this->decoratedConnection, 'getNativeConnection')) {
throw new \BadMethodCallException(sprintf('The connection "%s" does not support accessing the native connection.', \get_class($this->decoratedConnection)));
}

return $this->decoratedConnection->getNativeConnection();
}

/**
* {@inheritdoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use Doctrine\DBAL\Driver\Connection;

/**
* @method resource|object getNativeConnection()
*/
interface TracingDriverConnectionInterface extends Connection
{
public function getWrappedConnection(): Connection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@ public function getServerVersion(): string
return $wrappedConnection->getServerVersion();
}

/**
* {@inheritdoc}
*
* @return resource|object
*/
public function getNativeConnection()
{
if (!method_exists($this->decoratedConnection, 'getNativeConnection')) {
throw new \BadMethodCallException(sprintf('The connection "%s" does not support accessing the native connection.', \get_class($this->decoratedConnection)));
}

return $this->decoratedConnection->getNativeConnection();
}

/**
* {@inheritdoc}
*/
Expand Down
2 changes: 2 additions & 0 deletions tests/DependencyInjection/Fixtures/php/full.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
'send_default_pii' => true,
'max_value_length' => 255,
'http_proxy' => 'proxy.example.com:8080',
'http_timeout' => 10,
'http_connect_timeout' => 15,
'capture_silenced_errors' => true,
'max_request_body_size' => 'none',
'class_serializers' => ['App\\FooClass' => 'App\\Sentry\\Serializer\\FooClassSerializer'],
Expand Down
2 changes: 2 additions & 0 deletions tests/DependencyInjection/Fixtures/xml/full.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
send-default-pii="true"
max-value-length="255"
http-proxy="proxy.example.com:8080"
http-timeout="10"
http-connect-timeout="15"
capture-silenced-errors="true"
max-request-body-size="none"
>
Expand Down
2 changes: 2 additions & 0 deletions tests/DependencyInjection/Fixtures/yml/full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ sentry:
send_default_pii: true
max_value_length: 255
http_proxy: proxy.example.com:8080
http_timeout: 10
http_connect_timeout: 15
capture_silenced_errors: true
max_request_body_size: 'none'
class_serializers:
Expand Down
2 changes: 2 additions & 0 deletions tests/DependencyInjection/SentryExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ public function testClientIsCreatedFromOptions(): void
'send_default_pii' => true,
'max_value_length' => 255,
'http_proxy' => 'proxy.example.com:8080',
'http_timeout' => 10,
'http_connect_timeout' => 15,
'capture_silenced_errors' => true,
'max_request_body_size' => 'none',
'class_serializers' => [
Expand Down
2 changes: 1 addition & 1 deletion tests/End2End/App/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sentry:
tracing:
enabled: true
options:
capture_silenced_errors: true
capture_silenced_errors: false
error_types: E_ALL & ~E_USER_DEPRECATED
traces_sample_rate: 0

Expand Down
9 changes: 9 additions & 0 deletions tests/End2End/End2EndTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,15 @@ public function testGetFatal(): void
public function testNotice(): void
{
$client = static::createClient();

/** @var HubInterface $hub */
$hub = $client->getContainer()->get('test.hub');
$sentryClient = $hub->getClient();

$this->assertNotNull($sentryClient);

$sentryClient->getOptions()->setCaptureSilencedErrors(true);

$client->request('GET', '/notice');

$response = $client->getResponse();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace Sentry\SentryBundle\Tests\Tracing\Doctrine\DBAL\Fixture;

use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnectionInterface;

interface NativeDriverConnectionInterfaceStub extends TracingDriverConnectionInterface
{
/**
* @return object|resource
*/
public function getNativeConnection();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Sentry\SentryBundle\Tests\Tracing\Doctrine\DBAL;
namespace Sentry\SentryBundle\Tests\Tracing\Doctrine\DBAL\Fixture;

use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use PHPUnit\Framework\MockObject\MockObject;
use Sentry\SentryBundle\Tests\DoctrineTestCase;
use Sentry\SentryBundle\Tests\Tracing\Doctrine\DBAL\Fixture\ServerInfoAwareConnectionStub;
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnection;
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnectionFactory;
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingServerInfoAwareDriverConnection;
Expand Down
28 changes: 28 additions & 0 deletions tests/Tracing/Doctrine/DBAL/TracingDriverConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
use Doctrine\DBAL\ParameterType;
use PHPUnit\Framework\MockObject\MockObject;
use Sentry\SentryBundle\Tests\DoctrineTestCase;
use Sentry\SentryBundle\Tests\Tracing\Doctrine\DBAL\Fixture\NativeDriverConnectionInterfaceStub;
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnection;
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnectionInterface;
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingStatement;
use Sentry\State\HubInterface;
use Sentry\Tracing\Transaction;
Expand Down Expand Up @@ -417,6 +419,32 @@ public function testGetWrappedConnection(): void
$this->assertSame($this->decoratedConnection, $connection->getWrappedConnection());
}

public function testGetNativeConnection(): void
{
$nativeConnection = new class() {
};

$decoratedConnection = $this->createMock(NativeDriverConnectionInterfaceStub::class);
$decoratedConnection->expects($this->once())
->method('getNativeConnection')
->willReturn($nativeConnection);

$connection = new TracingDriverConnection($this->hub, $decoratedConnection, 'foo_platform', []);

$this->assertSame($nativeConnection, $connection->getNativeConnection());
}

public function testGetNativeConnectionThrowsExceptionIfDecoratedConnectionDoesNotImplementMethod(): void
{
$decoratedConnection = $this->createMock(TracingDriverConnectionInterface::class);
$connection = new TracingDriverConnection($this->hub, $decoratedConnection, 'foo_platform', []);

$this->expectException(\BadMethodCallException::class);
$this->expectExceptionMessageMatches('/The connection ".*?" does not support accessing the native connection\./');

$connection->getNativeConnection();
}

/**
* @return \Generator<mixed>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use Doctrine\DBAL\ParameterType;
use PHPUnit\Framework\MockObject\MockObject;
use Sentry\SentryBundle\Tests\DoctrineTestCase;
use Sentry\SentryBundle\Tests\Tracing\Doctrine\DBAL\Fixture\NativeDriverConnectionInterfaceStub;
use Sentry\SentryBundle\Tests\Tracing\Doctrine\DBAL\Fixture\ServerInfoAwareConnectionStub;
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnectionInterface;
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingServerInfoAwareDriverConnection;

Expand Down Expand Up @@ -256,4 +258,30 @@ public function testGetWrappedConnection(): void

$this->assertSame($wrappedConnection, $this->connection->getWrappedConnection());
}

public function testGetNativeConnection(): void
{
$nativeConnection = new class() {
};

$decoratedConnection = $this->createMock(NativeDriverConnectionInterfaceStub::class);
$decoratedConnection->expects($this->once())
->method('getNativeConnection')
->willReturn($nativeConnection);

$connection = new TracingServerInfoAwareDriverConnection($decoratedConnection);

$this->assertSame($nativeConnection, $connection->getNativeConnection());
}

public function testGetNativeConnectionThrowsExceptionIfDecoratedConnectionDoesNotImplementMethod(): void
{
$decoratedConnection = $this->createMock(TracingDriverConnectionInterface::class);
$connection = new TracingServerInfoAwareDriverConnection($decoratedConnection);

$this->expectException(\BadMethodCallException::class);
$this->expectExceptionMessageMatches('/The connection ".*?" does not support accessing the native connection\./');

$connection->getNativeConnection();
}
}

0 comments on commit 12d0f96

Please sign in to comment.