Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ff00f8f

Browse filesBrowse files
Merge branch '4.4' into 5.3
* 4.4: [VarDumper] fix dumping typed references from properties Update README.md [Messenger] [Redis] Allow authentication with user and password
2 parents b3e1322 + f5d9d1d commit ff00f8f
Copy full SHA for ff00f8f

File tree

5 files changed

+98
-24
lines changed
Filter options

5 files changed

+98
-24
lines changed

‎src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/ConnectionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/ConnectionTest.php
+14-3Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,26 @@ public function testKeepGettingPendingMessages()
163163
$this->assertNotNull($connection->get());
164164
}
165165

166-
public function testAuth()
166+
/**
167+
* @param string|array $expected
168+
*
169+
* @dataProvider provideAuthDsn
170+
*/
171+
public function testAuth($expected, string $dsn)
167172
{
168173
$redis = $this->createMock(\Redis::class);
169174

170175
$redis->expects($this->exactly(1))->method('auth')
171-
->with('password')
176+
->with($expected)
172177
->willReturn(true);
173178

174-
Connection::fromDsn('redis://password@localhost/queue', [], $redis);
179+
Connection::fromDsn($dsn, [], $redis);
180+
}
181+
182+
public function provideAuthDsn(): \Generator
183+
{
184+
yield 'Password only' => ['password', 'redis://password@localhost/queue'];
185+
yield 'User and password' => [['user', 'password'], 'redis://user:password@localhost/queue'];
175186
}
176187

177188
public function testAuthFromOptions()

‎src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ public static function fromDsn(string $dsn, array $redisOptions = [], $redis = n
233233
$connectionCredentials = [
234234
'host' => $parsedUrl['host'] ?? '127.0.0.1',
235235
'port' => $parsedUrl['port'] ?? 6379,
236-
'auth' => $redisOptions['auth'] ?? $parsedUrl['pass'] ?? $parsedUrl['user'] ?? null,
236+
// See: https://github.com/phpredis/phpredis/#auth
237+
'auth' => $redisOptions['auth'] ?? (isset($parsedUrl['pass']) && isset($parsedUrl['user']) ? [$parsedUrl['user'], $parsedUrl['pass']] : $parsedUrl['pass'] ?? $parsedUrl['user'] ?? null),
237238
];
238239

239240
$pathParts = explode('/', rtrim($parsedUrl['path'] ?? '', '/'));

‎src/Symfony/Component/VarDumper/Cloner/VarCloner.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Cloner/VarCloner.php
+32-15Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,29 +66,39 @@ protected function doClone($var)
6666
// $v is the original value or a stub object in case of hard references
6767

6868
if (\PHP_VERSION_ID >= 70400) {
69-
$zvalIsRef = null !== \ReflectionReference::fromArrayElement($vals, $k);
69+
$zvalRef = ($r = \ReflectionReference::fromArrayElement($vals, $k)) ? $r->getId() : null;
7070
} else {
7171
$refs[$k] = $cookie;
72-
$zvalIsRef = $vals[$k] === $cookie;
72+
$zvalRef = $vals[$k] === $cookie;
7373
}
7474

75-
if ($zvalIsRef) {
75+
if ($zvalRef) {
7676
$vals[$k] = &$stub; // Break hard references to make $queue completely
7777
unset($stub); // independent from the original structure
78-
if ($v instanceof Stub && isset($hardRefs[spl_object_id($v)])) {
79-
$vals[$k] = $refs[$k] = $v;
78+
if (\PHP_VERSION_ID >= 70400 ? null !== $vals[$k] = $hardRefs[$zvalRef] ?? null : $v instanceof Stub && isset($hardRefs[spl_object_id($v)])) {
79+
if (\PHP_VERSION_ID >= 70400) {
80+
$v = $vals[$k];
81+
} else {
82+
$refs[$k] = $vals[$k] = $v;
83+
}
8084
if ($v->value instanceof Stub && (Stub::TYPE_OBJECT === $v->value->type || Stub::TYPE_RESOURCE === $v->value->type)) {
8185
++$v->value->refCount;
8286
}
8387
++$v->refCount;
8488
continue;
8589
}
86-
$refs[$k] = $vals[$k] = new Stub();
87-
$refs[$k]->value = $v;
88-
$h = spl_object_id($refs[$k]);
89-
$hardRefs[$h] = &$refs[$k];
90-
$values[$h] = $v;
90+
$vals[$k] = new Stub();
91+
$vals[$k]->value = $v;
9192
$vals[$k]->handle = ++$refsCounter;
93+
94+
if (\PHP_VERSION_ID >= 70400) {
95+
$hardRefs[$zvalRef] = $vals[$k];
96+
} else {
97+
$refs[$k] = $vals[$k];
98+
$h = spl_object_id($refs[$k]);
99+
$hardRefs[$h] = &$refs[$k];
100+
$values[$h] = $v;
101+
}
92102
}
93103
// Create $stub when the original value $v can not be used directly
94104
// If $v is a nested structure, put that structure in array $a
@@ -147,12 +157,17 @@ protected function doClone($var)
147157
unset($v[$gid]);
148158
$a = [];
149159
foreach ($v as $gk => &$gv) {
150-
if ($v === $gv) {
160+
if ($v === $gv && (\PHP_VERSION_ID < 70400 || !isset($hardRefs[\ReflectionReference::fromArrayElement($v, $gk)->getId()]))) {
151161
unset($v);
152162
$v = new Stub();
153163
$v->value = [$v->cut = \count($gv), Stub::TYPE_ARRAY => 0];
154164
$v->handle = -1;
155-
$gv = &$hardRefs[spl_object_id($v)];
165+
if (\PHP_VERSION_ID >= 70400) {
166+
$gv = &$a[$gk];
167+
$hardRefs[\ReflectionReference::fromArrayElement($a, $gk)->getId()] = &$gv;
168+
} else {
169+
$gv = &$hardRefs[spl_object_id($v)];
170+
}
156171
$gv = $v;
157172
}
158173

@@ -251,10 +266,12 @@ protected function doClone($var)
251266
}
252267
}
253268

254-
if ($zvalIsRef) {
255-
$refs[$k]->value = $stub;
256-
} else {
269+
if (!$zvalRef) {
257270
$vals[$k] = $stub;
271+
} elseif (\PHP_VERSION_ID >= 70400) {
272+
$hardRefs[$zvalRef]->value = $stub;
273+
} else {
274+
$refs[$k]->value = $stub;
258275
}
259276
}
260277

‎src/Symfony/Component/VarDumper/Tests/Cloner/VarClonerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Tests/Cloner/VarClonerTest.php
+48-5Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,55 @@ public function testPhp74()
499499
[p1] => 123
500500
[p2] => Symfony\Component\VarDumper\Cloner\Stub Object
501501
(
502-
[type] => 4
503-
[class] => stdClass
504-
[value] =>
502+
[type] => 1
503+
[class] =>
504+
[value] => Symfony\Component\VarDumper\Cloner\Stub Object
505+
(
506+
[type] => 4
507+
[class] => stdClass
508+
[value] =>
509+
[cut] => 0
510+
[handle] => %i
511+
[refCount] => 1
512+
[position] => 0
513+
[attr] => Array
514+
(
515+
)
516+
517+
)
518+
505519
[cut] => 0
506-
[handle] => %i
507-
[refCount] => 0
520+
[handle] => 1
521+
[refCount] => 1
522+
[position] => 0
523+
[attr] => Array
524+
(
525+
)
526+
527+
)
528+
529+
[p3] => Symfony\Component\VarDumper\Cloner\Stub Object
530+
(
531+
[type] => 1
532+
[class] =>
533+
[value] => Symfony\Component\VarDumper\Cloner\Stub Object
534+
(
535+
[type] => 4
536+
[class] => stdClass
537+
[value] =>
538+
[cut] => 0
539+
[handle] => %i
540+
[refCount] => 1
541+
[position] => 0
542+
[attr] => Array
543+
(
544+
)
545+
546+
)
547+
548+
[cut] => 0
549+
[handle] => 1
550+
[refCount] => 1
508551
[position] => 0
509552
[attr] => Array
510553
(

‎src/Symfony/Component/VarDumper/Tests/Fixtures/Php74.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Tests/Fixtures/Php74.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ class Php74
66
{
77
public $p1 = 123;
88
public \stdClass $p2;
9+
public \stdClass $p3;
910

1011
public function __construct()
1112
{
1213
$this->p2 = new \stdClass();
14+
$this->p3 = &$this->p2;
1315
}
1416
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.