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 37f04cf

Browse filesBrowse files
Merge branch '7.0' into 7.1
* 7.0: [Messenger] Fix support for Redis Sentinel using php-redis 6.0.0 update the default branch for scorecards [Cache][Lock] `PdoAdapter`/`PdoStore` minor cleanup name exception being caught as it is accessed in the catch block fix tests name exception being caught as it is accessed in the catch block [Security] remove conflict with symfony/security-guard Fix error cannot use object of type as array
2 parents e0de63d + c9ac1b9 commit 37f04cf
Copy full SHA for 37f04cf

File tree

Expand file treeCollapse file tree

7 files changed

+58
-68
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+58
-68
lines changed

‎.github/workflows/scorecards.yml

Copy file name to clipboardExpand all lines: .github/workflows/scorecards.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
schedule:
77
- cron: '34 4 * * 6'
88
push:
9-
branches: [ "6.4" ]
9+
branches: [ "7.1" ]
1010

1111
# Declare default permissions as read only.
1212
permissions: read-all

‎src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private function dumpData(mixed $data, bool $colors = null): string
188188
$this->dumper->setColors($colors);
189189
}
190190

191-
if (($data['data'] ?? null) instanceof Data) {
191+
if (\is_array($data) && ($data['data'] ?? null) instanceof Data) {
192192
$data = $data['data'];
193193
} elseif (!$data instanceof Data) {
194194
$data = $this->cloner->cloneVar($data);

‎src/Symfony/Component/Cache/Adapter/PdoAdapter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Adapter/PdoAdapter.php
+25-26Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,7 @@ public function __construct(#[\SensitiveParameter] \PDO|string $connOrDsn, strin
100100
*/
101101
public function createTable(): void
102102
{
103-
// connect if we are not yet
104-
$conn = $this->getConnection();
105-
106-
$sql = match ($this->driver) {
103+
$sql = match ($driver = $this->getDriver()) {
107104
// We use varbinary for the ID column because it prevents unwanted conversions:
108105
// - character set conversions between server and client
109106
// - trailing space removal
@@ -114,10 +111,10 @@ public function createTable(): void
114111
'pgsql' => "CREATE TABLE $this->table ($this->idCol VARCHAR(255) NOT NULL PRIMARY KEY, $this->dataCol BYTEA NOT NULL, $this->lifetimeCol INTEGER, $this->timeCol INTEGER NOT NULL)",
115112
'oci' => "CREATE TABLE $this->table ($this->idCol VARCHAR2(255) NOT NULL PRIMARY KEY, $this->dataCol BLOB NOT NULL, $this->lifetimeCol INTEGER, $this->timeCol INTEGER NOT NULL)",
116113
'sqlsrv' => "CREATE TABLE $this->table ($this->idCol VARCHAR(255) NOT NULL PRIMARY KEY, $this->dataCol VARBINARY(MAX) NOT NULL, $this->lifetimeCol INTEGER, $this->timeCol INTEGER NOT NULL)",
117-
default => throw new \DomainException(sprintf('Creating the cache table is currently not implemented for PDO driver "%s".', $this->driver)),
114+
default => throw new \DomainException(sprintf('Creating the cache table is currently not implemented for PDO driver "%s".', $driver)),
118115
};
119116

120-
$conn->exec($sql);
117+
$this->getConnection()->exec($sql);
121118
}
122119

123120
public function prune(): bool
@@ -209,7 +206,7 @@ protected function doClear(string $namespace): bool
209206
$conn = $this->getConnection();
210207

211208
if ('' === $namespace) {
212-
if ('sqlite' === $this->driver) {
209+
if ('sqlite' === $this->getDriver()) {
213210
$sql = "DELETE FROM $this->table";
214211
} else {
215212
$sql = "TRUNCATE TABLE $this->table";
@@ -247,7 +244,7 @@ protected function doSave(array $values, int $lifetime): array|bool
247244

248245
$conn = $this->getConnection();
249246

250-
$driver = $this->driver;
247+
$driver = $this->getDriver();
251248
$insertSql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)";
252249

253250
switch (true) {
@@ -283,8 +280,8 @@ protected function doSave(array $values, int $lifetime): array|bool
283280
$lifetime = $lifetime ?: null;
284281
try {
285282
$stmt = $conn->prepare($sql);
286-
} catch (\PDOException) {
287-
if ($this->isTableMissing($e) && (!$conn->inTransaction() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true))) {
283+
} catch (\PDOException $e) {
284+
if ($this->isTableMissing($e) && (!$conn->inTransaction() || \in_array($driver, ['pgsql', 'sqlite', 'sqlsrv'], true))) {
288285
$this->createTable();
289286
}
290287
$stmt = $conn->prepare($sql);
@@ -318,8 +315,8 @@ protected function doSave(array $values, int $lifetime): array|bool
318315
foreach ($values as $id => $data) {
319316
try {
320317
$stmt->execute();
321-
} catch (\PDOException) {
322-
if ($this->isTableMissing($e) && (!$conn->inTransaction() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true))) {
318+
} catch (\PDOException $e) {
319+
if ($this->isTableMissing($e) && (!$conn->inTransaction() || \in_array($driver, ['pgsql', 'sqlite', 'sqlsrv'], true))) {
323320
$this->createTable();
324321
}
325322
$stmt->execute();
@@ -341,7 +338,7 @@ protected function doSave(array $values, int $lifetime): array|bool
341338
*/
342339
protected function getId(mixed $key): string
343340
{
344-
if ('pgsql' !== $this->driver ??= ($this->getConnection() ? $this->driver : null)) {
341+
if ('pgsql' !== $this->getDriver()) {
345342
return parent::getId($key);
346343
}
347344

@@ -358,30 +355,32 @@ private function getConnection(): \PDO
358355
$this->conn = new \PDO($this->dsn, $this->username, $this->password, $this->connectionOptions);
359356
$this->conn->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
360357
}
361-
$this->driver ??= $this->conn->getAttribute(\PDO::ATTR_DRIVER_NAME);
362358

363359
return $this->conn;
364360
}
365361

362+
private function getDriver(): string
363+
{
364+
return $this->driver ??= $this->getConnection()->getAttribute(\PDO::ATTR_DRIVER_NAME);
365+
}
366+
366367
private function getServerVersion(): string
367368
{
368-
return $this->serverVersion ??= $this->conn->getAttribute(\PDO::ATTR_SERVER_VERSION);
369+
return $this->serverVersion ??= $this->getConnection()->getAttribute(\PDO::ATTR_SERVER_VERSION);
369370
}
370371

371372
private function isTableMissing(\PDOException $exception): bool
372373
{
373-
$driver = $this->driver;
374+
$driver = $this->getDriver();
374375
$code = $exception->getCode();
375376

376-
switch (true) {
377-
case 'pgsql' === $driver && '42P01' === $code:
378-
case 'sqlite' === $driver && str_contains($exception->getMessage(), 'no such table:'):
379-
case 'oci' === $driver && 942 === $code:
380-
case 'sqlsrv' === $driver && 208 === $code:
381-
case 'mysql' === $driver && 1146 === $code:
382-
return true;
383-
default:
384-
return false;
385-
}
377+
return match ($driver) {
378+
'pgsql' => '42P01' === $code,
379+
'sqlite' => str_contains($exception->getMessage(), 'no such table:'),
380+
'oci' => 942 === $code,
381+
'sqlsrv' => 208 === $code,
382+
'mysql' => 1146 === $code,
383+
default => false,
384+
};
386385
}
387386
}

‎src/Symfony/Component/Lock/Store/PdoStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/PdoStore.php
+16-29Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ public function save(Key $key): void
9191
$conn = $this->getConnection();
9292
try {
9393
$stmt = $conn->prepare($sql);
94-
} catch (\PDOException) {
95-
if ($this->isTableMissing($e) && (!$conn->inTransaction() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true))) {
94+
} catch (\PDOException $e) {
95+
if ($this->isTableMissing($e) && (!$conn->inTransaction() || \in_array($this->getDriver(), ['pgsql', 'sqlite', 'sqlsrv'], true))) {
9696
$this->createTable();
9797
}
9898
$stmt = $conn->prepare($sql);
@@ -103,13 +103,13 @@ public function save(Key $key): void
103103

104104
try {
105105
$stmt->execute();
106-
} catch (\PDOException) {
107-
if ($this->isTableMissing($e) && (!$conn->inTransaction() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true))) {
106+
} catch (\PDOException $e) {
107+
if ($this->isTableMissing($e) && (!$conn->inTransaction() || \in_array($this->getDriver(), ['pgsql', 'sqlite', 'sqlsrv'], true))) {
108108
$this->createTable();
109109

110110
try {
111111
$stmt->execute();
112-
} catch (\PDOException $e) {
112+
} catch (\PDOException) {
113113
$this->putOffExpiration($key, $this->initialTtl);
114114
}
115115
} else {
@@ -187,11 +187,7 @@ private function getConnection(): \PDO
187187
*/
188188
public function createTable(): void
189189
{
190-
// connect if we are not yet
191-
$conn = $this->getConnection();
192-
$driver = $this->getDriver();
193-
194-
$sql = match ($driver) {
190+
$sql = match ($driver = $this->getDriver()) {
195191
'mysql' => "CREATE TABLE $this->table ($this->idCol VARCHAR(64) NOT NULL PRIMARY KEY, $this->tokenCol VARCHAR(44) NOT NULL, $this->expirationCol INTEGER UNSIGNED NOT NULL) COLLATE utf8mb4_bin, ENGINE = InnoDB",
196192
'sqlite' => "CREATE TABLE $this->table ($this->idCol TEXT NOT NULL PRIMARY KEY, $this->tokenCol TEXT NOT NULL, $this->expirationCol INTEGER)",
197193
'pgsql' => "CREATE TABLE $this->table ($this->idCol VARCHAR(64) NOT NULL PRIMARY KEY, $this->tokenCol VARCHAR(64) NOT NULL, $this->expirationCol INTEGER)",
@@ -200,7 +196,7 @@ public function createTable(): void
200196
default => throw new \DomainException(sprintf('Creating the lock table is currently not implemented for platform "%s".', $driver)),
201197
};
202198

203-
$conn->exec($sql);
199+
$this->getConnection()->exec($sql);
204200
}
205201

206202
/**
@@ -215,14 +211,7 @@ private function prune(): void
215211

216212
private function getDriver(): string
217213
{
218-
if (isset($this->driver)) {
219-
return $this->driver;
220-
}
221-
222-
$conn = $this->getConnection();
223-
$this->driver = $conn->getAttribute(\PDO::ATTR_DRIVER_NAME);
224-
225-
return $this->driver;
214+
return $this->driver ??= $this->getConnection()->getAttribute(\PDO::ATTR_DRIVER_NAME);
226215
}
227216

228217
/**
@@ -245,15 +234,13 @@ private function isTableMissing(\PDOException $exception): bool
245234
$driver = $this->getDriver();
246235
$code = $exception->getCode();
247236

248-
switch (true) {
249-
case 'pgsql' === $driver && '42P01' === $code:
250-
case 'sqlite' === $driver && str_contains($exception->getMessage(), 'no such table:'):
251-
case 'oci' === $driver && 942 === $code:
252-
case 'sqlsrv' === $driver && 208 === $code:
253-
case 'mysql' === $driver && 1146 === $code:
254-
return true;
255-
default:
256-
return false;
257-
}
237+
return match ($driver) {
238+
'pgsql' => '42P01' === $code,
239+
'sqlite' => str_contains($exception->getMessage(), 'no such table:'),
240+
'oci' => 942 === $code,
241+
'sqlsrv' => 208 === $code,
242+
'mysql' => 1146 === $code,
243+
default => false,
244+
};
258245
}
259246
}

‎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
+15-1Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,21 @@ public function __construct(array $options, \Redis|Relay|\RedisCluster $redis =
108108
}
109109

110110
try {
111-
$sentinel = new $sentinelClass($host, $port, $options['timeout'], $options['persistent_id'], $options['retry_interval'], $options['read_timeout']);
111+
if (\extension_loaded('redis') && version_compare(phpversion('redis'), '6.0.0', '>=')) {
112+
$params = [
113+
'host' => $host,
114+
'port' => $port,
115+
'connectTimeout' => $options['timeout'],
116+
'persistent' => $options['persistent_id'],
117+
'retryInterval' => $options['retry_interval'],
118+
'readTimeout' => $options['read_timeout'],
119+
];
120+
121+
$sentinel = new \RedisSentinel($params);
122+
} else {
123+
$sentinel = new $sentinelClass($host, $port, $options['timeout'], $options['persistent_id'], $options['retry_interval'], $options['read_timeout']);
124+
}
125+
112126
if ($address = $sentinel->getMasterAddrByName($sentinelMaster)) {
113127
[$host, $port] = $address;
114128
}

‎src/Symfony/Component/Security/Core/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/composer.json
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"conflict": {
3838
"symfony/event-dispatcher": "<6.4",
3939
"symfony/http-foundation": "<6.4",
40-
"symfony/security-guard": "<6.4",
4140
"symfony/ldap": "<6.4",
4241
"symfony/validator": "<6.4"
4342
},

‎src/Symfony/Component/Serializer/Tests/SerializerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/SerializerTest.php
-9Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,15 +1047,6 @@ public function testCollectDenormalizationErrors(?ClassMetadataFactory $classMet
10471047
'useMessageForUser' => false,
10481048
'message' => 'The type of the "something" attribute for class "Symfony\Component\Serializer\Tests\Fixtures\Php74FullWithTypedConstructor" must be one of "float" ("string" given).',
10491049
],
1050-
[
1051-
'currentType' => 'string',
1052-
'expectedTypes' => [
1053-
'float',
1054-
],
1055-
'path' => 'php74FullWithTypedConstructor.something',
1056-
'useMessageForUser' => false,
1057-
'message' => 'The type of the "something" attribute for class "Symfony\Component\Serializer\Tests\Fixtures\Php74FullWithTypedConstructor" must be one of "float" ("string" given).',
1058-
],
10591050
[
10601051
'currentType' => 'string',
10611052
'expectedTypes' => [

0 commit comments

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