New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support sentry/sentry 2.3 and fix deprecations #298
Changes from 16 commits
c816f94
9619847
135fa2a
41fc75c
cb5df80
972e375
be42948
4776060
cf0a1a0
393337e
22db0e1
68f7bf2
78f27cd
b171f4d
8dcdd06
c28319d
43f3208
a44ca03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ | |
backupGlobals="false" | ||
bootstrap="vendor/autoload.php" | ||
cacheResult="false" | ||
processIsolation="true" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've used an annotation directly on the only test that needs it, the |
||
> | ||
<php> | ||
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
namespace Sentry\SentryBundle\DependencyInjection; | ||
|
||
use Jean85\PrettyVersions; | ||
use PackageVersions\Versions; | ||
use Sentry\Options; | ||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; | ||
|
@@ -58,14 +57,10 @@ public function getConfigTreeBuilder(): TreeBuilder | |
->validate() | ||
->ifTrue($this->isNotAValidCallback()) | ||
->thenInvalid('Expecting callable or service reference, got %s'); | ||
if (PrettyVersions::getVersion('sentry/sentry')->getPrettyVersion() !== '2.0.0') { | ||
$optionsChildNodes->booleanNode('capture_silenced_errors'); | ||
} | ||
if ($this->classSerializersAreSupported()) { | ||
$optionsChildNodes->arrayNode('class_serializers') | ||
->defaultValue([]) | ||
->prototype('scalar'); | ||
} | ||
Comment on lines
-61
to
-68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here (and below) I've removed all the conditions that were needed for backward compatibility with |
||
$optionsChildNodes->booleanNode('capture_silenced_errors'); | ||
$optionsChildNodes->arrayNode('class_serializers') | ||
->defaultValue([]) | ||
->prototype('scalar'); | ||
$optionsChildNodes->integerNode('context_lines') | ||
->min(0) | ||
->max(99); | ||
|
@@ -75,14 +70,19 @@ public function getConfigTreeBuilder(): TreeBuilder | |
->defaultValue('%kernel.environment%') | ||
->cannotBeEmpty(); | ||
$optionsChildNodes->scalarNode('error_types'); | ||
$optionsChildNodes->arrayNode('in_app_include') | ||
->defaultValue([ | ||
'%kernel.project_dir%/src', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here I'm trying to guess the source folder, since using the parent is not feasibile due to getsentry/sentry-php#953 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Jean85 With the change in sentry-php 2.3.1 all files are now included by default. Therefore, wouldn't an empty default value make more sense? With the current default value There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is true, but it shouldn't have any practical effect you since you can override this default. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You still might want to remove it since it takes precedence over If you keep it empty by default you can just start using the It's not critical ofcourse but it is easier to not have it set and possibly make a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, that's true! Done in #311 |
||
]) | ||
->prototype('scalar'); | ||
$optionsChildNodes->arrayNode('in_app_exclude') | ||
->defaultValue([ | ||
'%kernel.cache_dir%', | ||
'%kernel.project_dir%/vendor', | ||
]) | ||
->prototype('scalar'); | ||
$optionsChildNodes->arrayNode('excluded_exceptions') | ||
->defaultValue($defaultValues->getExcludedExceptions()) | ||
->defaultValue([]) | ||
->prototype('scalar'); | ||
$optionsChildNodes->scalarNode('http_proxy'); | ||
$optionsChildNodes->arrayNode('integrations') | ||
|
@@ -97,24 +97,21 @@ public function getConfigTreeBuilder(): TreeBuilder | |
}) | ||
->thenInvalid('Expecting service reference, got "%s"'); | ||
$optionsChildNodes->scalarNode('logger'); | ||
if ($this->maxRequestBodySizeIsSupported()) { | ||
$optionsChildNodes->enumNode('max_request_body_size') | ||
->values([ | ||
'none', | ||
'small', | ||
'medium', | ||
'always', | ||
]); | ||
} | ||
$optionsChildNodes->enumNode('max_request_body_size') | ||
->values([ | ||
'none', | ||
'small', | ||
'medium', | ||
'always', | ||
]); | ||
$optionsChildNodes->integerNode('max_breadcrumbs') | ||
->min(1); | ||
$optionsChildNodes->integerNode('max_value_length') | ||
->min(1); | ||
$optionsChildNodes->arrayNode('prefixes') | ||
->defaultValue($defaultValues->getPrefixes()) | ||
->prototype('scalar'); | ||
$optionsChildNodes->scalarNode('project_root') | ||
->defaultValue('%kernel.project_dir%'); | ||
$optionsChildNodes->scalarNode('project_root'); | ||
$optionsChildNodes->scalarNode('release') | ||
->defaultValue(Versions::getVersion(Versions::ROOT_PACKAGE_NAME)) | ||
->info('Release version to be reported to sentry, see https://docs.sentry.io/workflow/releases/?platform=php') | ||
|
@@ -193,14 +190,4 @@ private function isNotAValidCallback(): \Closure | |
return true; | ||
}; | ||
} | ||
|
||
private function classSerializersAreSupported(): bool | ||
{ | ||
return method_exists(Options::class, 'getClassSerializers'); | ||
} | ||
|
||
private function maxRequestBodySizeIsSupported(): bool | ||
{ | ||
return method_exists(Options::class, 'getMaxRequestBodySize'); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Sentry\SentryBundle\DependencyInjection; | ||
|
||
use Sentry\Integration\ErrorListenerIntegration; | ||
use Sentry\Integration\ExceptionListenerIntegration; | ||
use Sentry\Integration\IntegrationInterface; | ||
|
||
class IntegrationFilterFactory | ||
{ | ||
public static function create(array $integrationsFromConfiguration): callable | ||
{ | ||
return function (array $integrations) use ($integrationsFromConfiguration) { | ||
$allIntegrations = array_merge($integrations, $integrationsFromConfiguration); | ||
|
||
return array_filter( | ||
$allIntegrations, | ||
static function (IntegrationInterface $integration): bool { | ||
if ($integration instanceof ErrorListenerIntegration) { | ||
return false; | ||
} | ||
|
||
if ($integration instanceof ExceptionListenerIntegration) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
); | ||
}; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
|
||
use Jean85\PrettyVersions; | ||
use Sentry\SentrySdk; | ||
use Sentry\State\Hub; | ||
use Sentry\State\HubInterface; | ||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
|
@@ -23,24 +22,14 @@ public static function getSdkVersion(): string | |
*/ | ||
public static function getCurrentHub(): HubInterface | ||
{ | ||
if (class_exists(SentrySdk::class)) { | ||
return SentrySdk::getCurrentHub(); | ||
} | ||
|
||
return Hub::getCurrent(); | ||
return SentrySdk::getCurrentHub(); | ||
} | ||
|
||
/** | ||
* This method avoids deprecations with sentry/sentry:^2.2 | ||
*/ | ||
public static function setCurrentHub(HubInterface $hub): void | ||
{ | ||
if (class_exists(SentrySdk::class)) { | ||
SentrySdk::setCurrentHub($hub); | ||
|
||
return; | ||
} | ||
|
||
Hub::setCurrent($hub); | ||
SentrySdk::setCurrentHub($hub); | ||
} | ||
Comment on lines
23
to
34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those two methods are left here for BC. |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This locks against
sentry/sentry:^2.3
. Because of this, this should be released as 3.4, to leave space for 3.3.x patches.