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

Commitfbcd80b

Browse files
committed
[Messenger] Use Doctrine DBAL new Types::* constants
1 parent88b89c9 commitfbcd80b

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

‎src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php‎

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
useDoctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer;
2121
useDoctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer;
2222
useDoctrine\DBAL\Types\Type;
23+
useDoctrine\DBAL\Types\Types;
2324
useSymfony\Component\Messenger\Exception\InvalidArgumentException;
2425
useSymfony\Component\Messenger\Exception\TransportException;
2526

@@ -53,12 +54,16 @@ class Connection
5354
private$schemaSynchronizer;
5455
private$autoSetup;
5556

57+
privatestatic$useDeprecatedConstants;
58+
5659
publicfunction__construct(array$configuration,DBALConnection$driverConnection,SchemaSynchronizer$schemaSynchronizer =null)
5760
{
5861
$this->configuration =array_replace_recursive(self::DEFAULT_OPTIONS,$configuration);
5962
$this->driverConnection =$driverConnection;
6063
$this->schemaSynchronizer =$schemaSynchronizer ??newSingleDatabaseSynchronizer($this->driverConnection);
6164
$this->autoSetup =$this->configuration['auto_setup'];
65+
66+
self::$useDeprecatedConstants =self::$useDeprecatedConstants ?? !class_exists(Types::class);
6267
}
6368

6469
publicfunctiongetConfiguration():array
@@ -125,12 +130,18 @@ public function send(string $body, array $headers, int $delay = 0): string
125130
$this->configuration['queue_name'],
126131
$now,
127132
$availableAt,
128-
], [
133+
],self::$useDeprecatedConstants ?[
129134
null,
130135
null,
131136
null,
132137
Type::DATETIME,
133138
Type::DATETIME,
139+
] : [
140+
null,
141+
null,
142+
null,
143+
Types::DATETIME_MUTABLE,
144+
Types::DATETIME_MUTABLE,
134145
]);
135146

136147
return$this->driverConnection->lastInsertId();
@@ -168,8 +179,8 @@ public function get(): ?array
168179
$this->executeQuery($queryBuilder->getSQL(), [
169180
$now,
170181
$doctrineEnvelope['id'],
171-
],[
172-
Type::DATETIME,
182+
],[
183+
self::$useDeprecatedConstants ?Type::DATETIME : Types::DATETIME_MUTABLE,
173184
]);
174185

175186
$this->driverConnection->commit();
@@ -278,9 +289,12 @@ private function createAvailableMessagesQueryBuilder(): QueryBuilder
278289
$redeliverLimit,
279290
$now,
280291
$this->configuration['queue_name'],
281-
], [
292+
],self::$useDeprecatedConstants ?[
282293
Type::DATETIME,
283294
Type::DATETIME,
295+
] : [
296+
Types::DATETIME_MUTABLE,
297+
Types::DATETIME_MUTABLE,
284298
]);
285299
}
286300

@@ -314,20 +328,20 @@ private function getSchema(): Schema
314328
{
315329
$schema =newSchema([], [],$this->driverConnection->getSchemaManager()->createSchemaConfig());
316330
$table =$schema->createTable($this->configuration['table_name']);
317-
$table->addColumn('id', Type::BIGINT)
331+
$table->addColumn('id',self::$useDeprecatedConstants ?Type::BIGINT : Types::BIGINT)
318332
->setAutoincrement(true)
319333
->setNotnull(true);
320-
$table->addColumn('body', Type::TEXT)
334+
$table->addColumn('body',self::$useDeprecatedConstants ?Type::TEXT : Types::TEXT)
321335
->setNotnull(true);
322-
$table->addColumn('headers', Type::TEXT)
336+
$table->addColumn('headers',self::$useDeprecatedConstants ?Type::TEXT : Types::TEXT)
323337
->setNotnull(true);
324-
$table->addColumn('queue_name', Type::STRING)
338+
$table->addColumn('queue_name',self::$useDeprecatedConstants ?Type::STRING : Types::STRING)
325339
->setNotnull(true);
326-
$table->addColumn('created_at', Type::DATETIME)
340+
$table->addColumn('created_at',self::$useDeprecatedConstants ?Type::DATETIME : Types::DATETIME_MUTABLE)
327341
->setNotnull(true);
328-
$table->addColumn('available_at', Type::DATETIME)
342+
$table->addColumn('available_at',self::$useDeprecatedConstants ?Type::DATETIME : Types::DATETIME_MUTABLE)
329343
->setNotnull(true);
330-
$table->addColumn('delivered_at', Type::DATETIME)
344+
$table->addColumn('delivered_at',self::$useDeprecatedConstants ?Type::DATETIME : Types::DATETIME_MUTABLE)
331345
->setNotnull(false);
332346
$table->setPrimaryKey(['id']);
333347
$table->addIndex(['queue_name']);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp