Skip to content

Commit 517493a

Browse files
committed
Merge branch 'master' into develop
2 parents e55c3e4 + dd37786 commit 517493a

9 files changed

+244
-25
lines changed

.github/workflows/stale.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: 'close stale issues/PRs'
2+
on:
3+
schedule:
4+
- cron: '* */3 * * *'
5+
workflow_dispatch:
6+
jobs:
7+
stale:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/stale@87c2b794b9b47a9bec68ae03c01aeb572ffebdb1
11+
with:
12+
repo-token: ${{ github.token }}
13+
days-before-stale: 21
14+
days-before-close: 7
15+
only-labels: ""
16+
operations-per-run: 100
17+
remove-stale-when-updated: true
18+
debug-only: false
19+
ascending: false
20+
21+
exempt-issue-labels: "Status: Backlog,Status: In Progress, Status: Confirmed, Status: Blocked"
22+
stale-issue-label: "Status: Stale"
23+
stale-issue-message: |-
24+
This issue has gone three weeks without activity. In another week, I will close it.
25+
26+
But! If you comment or otherwise update it, I will reset the clock, and if you label it `Status: Backlog` or `Status: In Progress`, I will leave it alone ... forever!
27+
28+
----
29+
30+
"A weed is but an unloved flower." ― _Ella Wheeler Wilcox_ 🥀
31+
skip-stale-issue-message: false
32+
close-issue-label: ""
33+
close-issue-message: ""
34+
35+
exempt-pr-labels: "Status: Backlog,Status: In Progress"
36+
stale-pr-label: "Status: Stale"
37+
stale-pr-message: |-
38+
This pull request has gone three weeks without activity. In another week, I will close it.
39+
40+
But! If you comment or otherwise update it, I will reset the clock, and if you label it `Status: Backlog` or `Status: In Progress`, I will leave it alone ... forever!
41+
42+
----
43+
44+
"A weed is but an unloved flower." ― _Ella Wheeler Wilcox_ 🥀
45+
skip-stale-pr-message: false
46+
close-pr-label:
47+
close-pr-message: ""

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
## 4.2.6 (2022-01-10)
6+
7+
- Add support for `symfony/cache-contracts` package version `3.x` (#588)
8+
59
## 4.2.5 (2021-12-13)
610

711
- Add support for Symfony 6 (#566)

composer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@
1616
}
1717
],
1818
"config": {
19-
"sort-packages": true
19+
"sort-packages": true,
20+
"allow-plugins": {
21+
"composer/package-versions-deprecated": true,
22+
"phpstan/extension-installer": true
23+
}
2024
},
2125
"require": {
2226
"php": "^7.2||^8.0",
2327
"jean85/pretty-package-versions": "^1.5 || ^2.0",
2428
"php-http/discovery": "^1.11",
2529
"sentry/sdk": "^3.1",
26-
"symfony/cache-contracts": "^1.1||^2.4",
30+
"symfony/cache-contracts": "^1.1||^2.4||^3.0",
2731
"symfony/config": "^3.4.44||^4.4.20||^5.0.11||^6.0",
2832
"symfony/console": "^3.4.44||^4.4.20||^5.0.11||^6.0",
2933
"symfony/dependency-injection": "^3.4.44||^4.4.20||^5.0.11||^6.0",
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Sentry\SentryBundle\Tracing\Cache;
6+
7+
use Sentry\State\HubInterface;
8+
use Symfony\Component\Cache\Adapter\AdapterInterface;
9+
use Symfony\Component\Cache\PruneableInterface;
10+
use Symfony\Component\Cache\ResettableInterface;
11+
use Symfony\Contracts\Cache\CacheInterface;
12+
13+
/**
14+
* This implementation of a cache adapter supports the distributed tracing
15+
* feature of Sentry.
16+
*
17+
* @internal
18+
*/
19+
final class TraceableCacheAdapterForV2 implements AdapterInterface, CacheInterface, PruneableInterface, ResettableInterface
20+
{
21+
/**
22+
* @phpstan-use TraceableCacheAdapterTrait<AdapterInterface>
23+
*/
24+
use TraceableCacheAdapterTrait;
25+
26+
/**
27+
* @param HubInterface $hub The current hub
28+
* @param AdapterInterface $decoratedAdapter The decorated cache adapter
29+
*/
30+
public function __construct(HubInterface $hub, AdapterInterface $decoratedAdapter)
31+
{
32+
$this->hub = $hub;
33+
$this->decoratedAdapter = $decoratedAdapter;
34+
}
35+
36+
/**
37+
* {@inheritdoc}
38+
*
39+
* @param mixed[] $metadata
40+
*
41+
* @return mixed
42+
*/
43+
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
44+
{
45+
return $this->traceFunction('cache.get_item', function () use ($key, $callback, $beta, &$metadata) {
46+
if (!$this->decoratedAdapter instanceof CacheInterface) {
47+
throw new \BadMethodCallException(sprintf('The %s::get() method is not supported because the decorated adapter does not implement the "%s" interface.', self::class, CacheInterface::class));
48+
}
49+
50+
return $this->decoratedAdapter->get($key, $callback, $beta, $metadata);
51+
});
52+
}
53+
}

src/Tracing/Cache/TraceableCacheAdapter.php renamed to src/Tracing/Cache/TraceableCacheAdapterForV3.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
/**
1414
* This implementation of a cache adapter supports the distributed tracing
1515
* feature of Sentry.
16+
*
17+
* @internal
1618
*/
17-
final class TraceableCacheAdapter implements AdapterInterface, CacheInterface, PruneableInterface, ResettableInterface
19+
final class TraceableCacheAdapterForV3 implements AdapterInterface, CacheInterface, PruneableInterface, ResettableInterface
1820
{
1921
/**
2022
* @phpstan-use TraceableCacheAdapterTrait<AdapterInterface>
@@ -30,4 +32,20 @@ public function __construct(HubInterface $hub, AdapterInterface $decoratedAdapte
3032
$this->hub = $hub;
3133
$this->decoratedAdapter = $decoratedAdapter;
3234
}
35+
36+
/**
37+
* {@inheritdoc}
38+
*
39+
* @param mixed[] $metadata
40+
*/
41+
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null): mixed
42+
{
43+
return $this->traceFunction('cache.get_item', function () use ($key, $callback, $beta, &$metadata) {
44+
if (!$this->decoratedAdapter instanceof CacheInterface) {
45+
throw new \BadMethodCallException(sprintf('The %s::get() method is not supported because the decorated adapter does not implement the "%s" interface.', self::class, CacheInterface::class));
46+
}
47+
48+
return $this->decoratedAdapter->get($key, $callback, $beta, $metadata);
49+
});
50+
}
3351
}

src/Tracing/Cache/TraceableCacheAdapterTrait.php

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ trait TraceableCacheAdapterTrait
3838
*/
3939
public function getItem($key): CacheItem
4040
{
41-
return $this->traceFunction('cache.get_item', function () use ($key) {
41+
return $this->traceFunction('cache.get_item', function () use ($key): CacheItem {
4242
return $this->decoratedAdapter->getItem($key);
4343
});
4444
}
@@ -48,7 +48,7 @@ public function getItem($key): CacheItem
4848
*/
4949
public function getItems(array $keys = []): iterable
5050
{
51-
return $this->traceFunction('cache.get_items', function () use ($keys) {
51+
return $this->traceFunction('cache.get_items', function () use ($keys): iterable {
5252
return $this->decoratedAdapter->getItems($keys);
5353
});
5454
}
@@ -63,30 +63,12 @@ public function clear(string $prefix = ''): bool
6363
});
6464
}
6565

66-
/**
67-
* {@inheritdoc}
68-
*
69-
* @param mixed[] $metadata
70-
*
71-
* @return mixed
72-
*/
73-
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
74-
{
75-
return $this->traceFunction('cache.get_item', function () use ($key, $callback, $beta, &$metadata) {
76-
if (!$this->decoratedAdapter instanceof CacheInterface) {
77-
throw new \BadMethodCallException(sprintf('The %s::get() method is not supported because the decorated adapter does not implement the "%s" interface.', self::class, CacheInterface::class));
78-
}
79-
80-
return $this->decoratedAdapter->get($key, $callback, $beta, $metadata);
81-
});
82-
}
83-
8466
/**
8567
* {@inheritdoc}
8668
*/
8769
public function delete(string $key): bool
8870
{
89-
return $this->traceFunction('cache.delete_item', function () use ($key) {
71+
return $this->traceFunction('cache.delete_item', function () use ($key): bool {
9072
if (!$this->decoratedAdapter instanceof CacheInterface) {
9173
throw new \BadMethodCallException(sprintf('The %s::delete() method is not supported because the decorated adapter does not implement the "%s" interface.', self::class, CacheInterface::class));
9274
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Sentry\SentryBundle\Tracing\Cache;
6+
7+
use Sentry\State\HubInterface;
8+
use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface;
9+
use Symfony\Component\Cache\PruneableInterface;
10+
use Symfony\Component\Cache\ResettableInterface;
11+
use Symfony\Contracts\Cache\CacheInterface;
12+
use Symfony\Contracts\Cache\TagAwareCacheInterface;
13+
14+
/**
15+
* This implementation of a cache adapter aware of cache tags supports the
16+
* distributed tracing feature of Sentry.
17+
*
18+
* @internal
19+
*/
20+
final class TraceableTagAwareCacheAdapterForV2 implements TagAwareAdapterInterface, TagAwareCacheInterface, PruneableInterface, ResettableInterface
21+
{
22+
/**
23+
* @phpstan-use TraceableCacheAdapterTrait<TagAwareAdapterInterface>
24+
*/
25+
use TraceableCacheAdapterTrait;
26+
27+
/**
28+
* @param HubInterface $hub The current hub
29+
* @param TagAwareAdapterInterface $decoratedAdapter The decorated cache adapter
30+
*/
31+
public function __construct(HubInterface $hub, TagAwareAdapterInterface $decoratedAdapter)
32+
{
33+
$this->hub = $hub;
34+
$this->decoratedAdapter = $decoratedAdapter;
35+
}
36+
37+
/**
38+
* {@inheritdoc}
39+
*
40+
* @param mixed[] $metadata
41+
*
42+
* @return mixed
43+
*/
44+
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
45+
{
46+
return $this->traceFunction('cache.get_item', function () use ($key, $callback, $beta, &$metadata) {
47+
if (!$this->decoratedAdapter instanceof CacheInterface) {
48+
throw new \BadMethodCallException(sprintf('The %s::get() method is not supported because the decorated adapter does not implement the "%s" interface.', self::class, CacheInterface::class));
49+
}
50+
51+
return $this->decoratedAdapter->get($key, $callback, $beta, $metadata);
52+
});
53+
}
54+
55+
/**
56+
* {@inheritdoc}
57+
*/
58+
public function invalidateTags(array $tags): bool
59+
{
60+
return $this->traceFunction('cache.invalidate_tags', function () use ($tags): bool {
61+
return $this->decoratedAdapter->invalidateTags($tags);
62+
});
63+
}
64+
}

src/Tracing/Cache/TraceableTagAwareCacheAdapter.php renamed to src/Tracing/Cache/TraceableTagAwareCacheAdapterForV3.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88
use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface;
99
use Symfony\Component\Cache\PruneableInterface;
1010
use Symfony\Component\Cache\ResettableInterface;
11+
use Symfony\Contracts\Cache\CacheInterface;
1112
use Symfony\Contracts\Cache\TagAwareCacheInterface;
1213

1314
/**
1415
* This implementation of a cache adapter aware of cache tags supports the
1516
* distributed tracing feature of Sentry.
17+
*
18+
* @internal
1619
*/
17-
final class TraceableTagAwareCacheAdapter implements TagAwareAdapterInterface, TagAwareCacheInterface, PruneableInterface, ResettableInterface
20+
final class TraceableTagAwareCacheAdapterForV3 implements TagAwareAdapterInterface, TagAwareCacheInterface, PruneableInterface, ResettableInterface
1821
{
1922
/**
2023
* @phpstan-use TraceableCacheAdapterTrait<TagAwareAdapterInterface>
@@ -31,6 +34,22 @@ public function __construct(HubInterface $hub, TagAwareAdapterInterface $decorat
3134
$this->decoratedAdapter = $decoratedAdapter;
3235
}
3336

37+
/**
38+
* {@inheritdoc}
39+
*
40+
* @param mixed[] $metadata
41+
*/
42+
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null): mixed
43+
{
44+
return $this->traceFunction('cache.get_item', function () use ($key, $callback, $beta, &$metadata) {
45+
if (!$this->decoratedAdapter instanceof CacheInterface) {
46+
throw new \BadMethodCallException(sprintf('The %s::get() method is not supported because the decorated adapter does not implement the "%s" interface.', self::class, CacheInterface::class));
47+
}
48+
49+
return $this->decoratedAdapter->get($key, $callback, $beta, $metadata);
50+
});
51+
}
52+
3453
/**
3554
* {@inheritdoc}
3655
*/

src/aliases.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,19 @@
1212
use Sentry\SentryBundle\EventListener\RequestListenerResponseEvent;
1313
use Sentry\SentryBundle\EventListener\RequestListenerTerminateEvent;
1414
use Sentry\SentryBundle\EventListener\SubRequestListenerRequestEvent;
15+
use Sentry\SentryBundle\Tracing\Cache\TraceableCacheAdapter;
16+
use Sentry\SentryBundle\Tracing\Cache\TraceableCacheAdapterForV2;
17+
use Sentry\SentryBundle\Tracing\Cache\TraceableCacheAdapterForV3;
18+
use Sentry\SentryBundle\Tracing\Cache\TraceableTagAwareCacheAdapter;
19+
use Sentry\SentryBundle\Tracing\Cache\TraceableTagAwareCacheAdapterForV2;
20+
use Sentry\SentryBundle\Tracing\Cache\TraceableTagAwareCacheAdapterForV3;
1521
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\Compatibility\MiddlewareInterface;
1622
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverForV2;
1723
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverForV3;
1824
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingStatementForV2;
1925
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingStatementForV3;
26+
use Symfony\Component\Cache\Adapter\AdapterInterface;
27+
use Symfony\Component\Cache\DoctrineProvider;
2028
use Symfony\Component\HttpKernel\Event\ControllerEvent;
2129
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
2230
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
@@ -79,6 +87,26 @@ class_alias(GetResponseEvent::class, SubRequestListenerRequestEvent::class);
7987
}
8088
}
8189

90+
if (interface_exists(AdapterInterface::class)) {
91+
if (!class_exists(DoctrineProvider::class, false) && version_compare(\PHP_VERSION, '8.0.0', '>=')) {
92+
if (!class_exists(TraceableCacheAdapter::class, false)) {
93+
class_alias(TraceableCacheAdapterForV3::class, TraceableCacheAdapter::class);
94+
}
95+
96+
if (!class_exists(TraceableTagAwareCacheAdapter::class, false)) {
97+
class_alias(TraceableTagAwareCacheAdapterForV3::class, TraceableTagAwareCacheAdapter::class);
98+
}
99+
} else {
100+
if (!class_exists(TraceableCacheAdapter::class, false)) {
101+
class_alias(TraceableCacheAdapterForV2::class, TraceableCacheAdapter::class);
102+
}
103+
104+
if (!class_exists(TraceableTagAwareCacheAdapter::class, false)) {
105+
class_alias(TraceableTagAwareCacheAdapterForV2::class, TraceableTagAwareCacheAdapter::class);
106+
}
107+
}
108+
}
109+
82110
if (!interface_exists(DoctrineMiddlewareInterface::class)) {
83111
class_alias(MiddlewareInterface::class, DoctrineMiddlewareInterface::class);
84112
}

0 commit comments

Comments
 (0)