Skip to content

Commit 0062f11

Browse files
bug #62096 [Cache] fix compatibility with Relay 0.12.1 (xabbuh)
This PR was merged into the 6.4 branch. Discussion ---------- [Cache] fix compatibility with Relay 0.12.1 | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | | License | MIT I missed to target the `6.4` branch for the changes done in #62087 that don't target the cluster implementation. Commits ------- 4e526c0 fix compatibility with Relay 0.12.1
2 parents 301e8c5 + 4e526c0 commit 0062f11

File tree

2 files changed

+53
-10
lines changed

2 files changed

+53
-10
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Cache\Traits\Relay;
13+
14+
if (version_compare(phpversion('relay'), '0.12.1', '>=')) {
15+
/**
16+
* @internal
17+
*/
18+
trait Relay121Trait
19+
{
20+
public function hgetWithMeta($hash, $member): \Relay\Relay|array|false
21+
{
22+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hgetWithMeta(...\func_get_args());
23+
}
24+
25+
public function select($db): \Relay\Relay|bool|string
26+
{
27+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->select(...\func_get_args());
28+
}
29+
30+
public function watch($key, ...$other_keys): \Relay\Relay|bool|string
31+
{
32+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->watch(...\func_get_args());
33+
}
34+
}
35+
} else {
36+
/**
37+
* @internal
38+
*/
39+
trait Relay121Trait
40+
{
41+
public function select($db): \Relay\Relay|bool
42+
{
43+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->select(...\func_get_args());
44+
}
45+
46+
public function watch($key, ...$other_keys): \Relay\Relay|bool
47+
{
48+
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->watch(...\func_get_args());
49+
}
50+
}
51+
}

src/Symfony/Component/Cache/Traits/RelayProxy.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Symfony\Component\Cache\Traits\Relay\NullableReturnTrait;
2424
use Symfony\Component\Cache\Traits\Relay\PfcountTrait;
2525
use Symfony\Component\Cache\Traits\Relay\Relay11Trait;
26+
use Symfony\Component\Cache\Traits\Relay\Relay121Trait;
2627
use Symfony\Component\Cache\Traits\Relay\Relay12Trait;
2728
use Symfony\Component\Cache\Traits\Relay\SwapdbTrait;
2829
use Symfony\Component\VarExporter\LazyObjectInterface;
@@ -56,6 +57,7 @@ class RelayProxy extends \Relay\Relay implements ResetInterface, LazyObjectInter
5657
use RelayProxyTrait;
5758
use Relay11Trait;
5859
use Relay12Trait;
60+
use Relay121Trait;
5961
use SwapdbTrait;
6062

6163
private const LAZY_OBJECT_PROPERTY_SCOPES = [];
@@ -250,11 +252,6 @@ public function rawCommand($cmd, ...$args): mixed
250252
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rawCommand(...\func_get_args());
251253
}
252254

253-
public function select($db): \Relay\Relay|bool
254-
{
255-
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->select(...\func_get_args());
256-
}
257-
258255
public function auth(#[\SensitiveParameter] $auth): bool
259256
{
260257
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->auth(...\func_get_args());
@@ -940,11 +937,6 @@ public function wait($replicas, $timeout): \Relay\Relay|false|int
940937
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->wait(...\func_get_args());
941938
}
942939

943-
public function watch($key, ...$other_keys): \Relay\Relay|bool
944-
{
945-
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->watch(...\func_get_args());
946-
}
947-
948940
public function unwatch(): \Relay\Relay|bool
949941
{
950942
return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->unwatch(...\func_get_args());

0 commit comments

Comments
 (0)