Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit952ca0e

Browse files
committed
Use TypeError & fix DBAL platform detection
1 parentf7d493a commit952ca0e

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

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

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
useSymfony\Component\Lock\Exception\InvalidArgumentException;
2020
useSymfony\Component\Lock\Exception\LockConflictedException;
2121
useSymfony\Component\Lock\Key;
22-
useSymfony\Component\Lock\PersistingStoreInterface;
22+
useSymfony\Component\Lock\SharedLockStoreInterface;
2323

2424
/**
2525
* DoctrineDbalPostgreSqlStore is a PersistingStoreInterface implementation using
@@ -53,7 +53,7 @@ public function __construct($connOrDsn)
5353
}
5454
$this->conn = DriverManager::getConnection(['url' =>$this->filterDsn($connOrDsn)]);
5555
}else {
56-
thrownewInvalidArgumentException(sprintf('"%s" requires Doctrine\DBAL\Connection instance orDSNstring as first argument, "%s" given.',__CLASS__,get_debug_type($connOrDsn)));
56+
thrownew\TypeError(sprintf('Argument 1 passed to"%s()" must be %s or string, "%s" given.',Connection::class,__METHOD__,get_debug_type($connOrDsn)));
5757
}
5858
}
5959

@@ -207,8 +207,9 @@ private function unlockShared(Key $key): void
207207

208208
/**
209209
* Check driver and remove scheme extension from DSN.
210-
* Input: pgsql+advisory://server/
211-
* Output: pgsql://server/
210+
* Input: pgsql+advisory://server/
211+
* Output: pgsql://server/
212+
*
212213
* @throws InvalidArgumentException when driver is not supported.
213214
*/
214215
privatefunctionfilterDsn(string$dsn):string
@@ -218,20 +219,15 @@ private function filterDsn(string $dsn): string
218219
}
219220

220221
[$scheme,$rest] =explode(':',$dsn,2);
221-
222-
$driver =$scheme;
223-
if (str_contains($scheme,'+')) {
224-
[$driver] =explode('+',$scheme,2);
225-
}
226-
227-
if (!in_array($driver, ['pgsql','postgres','postgresql'])) {
222+
$driver =strtok($scheme,'+');
223+
if (!\in_array($driver, ['pgsql','postgres','postgresql'])) {
228224
thrownewInvalidArgumentException(sprintf('The adapter "%s" does not support the "%s" driver.',__CLASS__,$driver));
229225
}
230226

231227
returnsprintf('%s:%s',$driver,$rest);
232228
}
233229

234-
privatefunctiongetInternalStore():PersistingStoreInterface
230+
privatefunctiongetInternalStore():SharedLockStoreInterface
235231
{
236232
$namespace =spl_object_hash($this->conn);
237233

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function __construct($connOrDsn, array $options = [], float $gcProbabilit
7070
}
7171
$this->conn = DriverManager::getConnection(['url' =>$connOrDsn]);
7272
}else {
73-
thrownewInvalidArgumentException(sprintf('"%s" requires "Doctrine\DBAL\Connection" instance orDSNstring as first argument, "%s" given.',__CLASS__,get_debug_type($connOrDsn)));
73+
thrownew\TypeError(sprintf('Argument 1 passed to"%s()" must be %s or string, "%s" given.',Connection::class,__METHOD__,get_debug_type($connOrDsn)));
7474
}
7575
}
7676

@@ -211,18 +211,21 @@ private function getCurrentTimestampStatement(): string
211211
$platform =$this->conn->getDatabasePlatform();
212212
switch (true) {
213213
case$platforminstanceof \Doctrine\DBAL\Platforms\MySQLPlatform:
214+
case$platforminstanceof \Doctrine\DBAL\Platforms\MySQL57Platform:
214215
return'UNIX_TIMESTAMP()';
215216

216217
case$platforminstanceof \Doctrine\DBAL\Platforms\SqlitePlatform:
217218
return'strftime(\'%s\',\'now\')';
218219

219220
case$platforminstanceof \Doctrine\DBAL\Platforms\PostgreSQLPlatform:
221+
case$platforminstanceof \Doctrine\DBAL\Platforms\PostgreSQL94Platform:
220222
return'CAST(EXTRACT(epoch FROM NOW()) AS INT)';
221223

222224
case$platforminstanceof \Doctrine\DBAL\Platforms\OraclePlatform:
223225
return'(SYSDATE - TO_DATE(\'19700101\',\'yyyymmdd\'))*86400 - TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone), 1, 3))*3600';
224226

225227
case$platforminstanceof \Doctrine\DBAL\Platforms\SQLServerPlatform:
228+
case$platforminstanceof \Doctrine\DBAL\Platforms\SQLServer2012Platform:
226229
return'DATEDIFF(s,\'1970-01-01\', GETUTCDATE())';
227230

228231
default:

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespaceSymfony\Component\Lock\Store;
1313

1414
useDoctrine\DBAL\Connection;
15-
useDoctrine\DBAL\DriverManager;
1615
useSymfony\Component\Lock\BlockingSharedLockStoreInterface;
1716
useSymfony\Component\Lock\BlockingStoreInterface;
1817
useSymfony\Component\Lock\Exception\InvalidArgumentException;

‎src/Symfony/Component/Lock/Tests/Store/PostgreSqlDbalStoreTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* @requires extension pdo_pgsql
2222
* @group integration
23-
* @legacy
23+
* @grouplegacy
2424
*/
2525
class PostgreSqlDbalStoreTestextends AbstractStoreTest
2626
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp