8000 [Messenger] Use Doctrine DBAL new Types::* constants · symfony/symfony@11eedf4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 11eedf4

Browse files
committed
[Messenger] Use Doctrine DBAL new Types::* constants
1 parent 88b89c9 commit 11eedf4

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

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

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

@@ -119,6 +120,7 @@ public function send(string $body, array $headers, int $delay = 0): string
119120
'available_at' => '?',
120121
]);
121122

123+
$useDeprecatedConstants = !class_exists(Types::class);
122124
$this->executeQuery($queryBuilder->getSQL(), [
123125
$body,
124126
json_encode($headers),
@@ -129,8 +131,8 @@ public function send(string $body, array $headers, int $delay = 0): string
129131
null,
130132
null,
131133
null,
132-
Type::DATETIME,
133-
Type::DATETIME,
134+
$useDeprecatedConstants ? Type::DATETIME : Types::DATETIME_MUTABLE,
135+
$useDeprecatedConstants ? Type::DATETIME : Types::DATETIME_MUTABLE,
134136
]);
135137

136138
return $this->driverConnection->lastInsertId();
@@ -168,8 +170,10 @@ public function get(): ?array
168170
$this->executeQuery($queryBuilder->getSQL(), [
169171
$now,
170172
$doctrineEnvelope['id'],
171-
], [
173+
], !class_exists(Types::class) ? [
172174
Type::DATETIME,
175+
] : [
176+
Types::DATETIME_MUTABLE,
173177
]);
174178

175179
$this->driverConnection->commit();
@@ -278,9 +282,12 @@ private function createAvailableMessagesQueryBuilder(): QueryBuilder
278282
$redeliverLimit,
279283
$now,
280284
$this->configuration['queue_name'],
281-
], [
285+
], !class_exists(Types::class) ? [
282286
Type::DATETIME,
283287
Type::DATETIME,
288+
] : [
289+
Types::DATETIME_MUTABLE,
290+
Types::DATETIME_MUTABLE,
284291
]);
285292
}
286293

@@ -314,20 +321,21 @@ private function getSchema(): Schema
314321
{
315322
$schema = new Schema([], [], $this->driverConnection->getSchemaManager()->createSchemaConfig());
316323
$table = $schema->createTable($this->configuration['table_name']);
317-
$table->addColumn('id', Type::BIGINT)
324+
$useDeprecatedConstants = !class_exists(Types::class);
325+
$table->addColumn('id', !$useDeprecatedConstants ? Type::BIGINT : Types::BIGINT)
318326
->setAutoincrement(true)
319327
->setNotnull(true);
320-
$table->addColumn('body', Type::TEXT)
328+
$table->addColumn('body', !$useDeprecatedConstants ? Type::TEXT : Types::TEXT)
321329
->setNotnull(true);
322-
$table->addColumn('headers', Type::TEXT)
330+
$table->addColumn('headers', !$useDeprecatedConstants ? Type::TEXT : Types::TEXT)
323331
->setNotnull(true);
324-
$table->addColumn('queue_name', Type::STRING)
332+
$table->addColumn('queue_name', !$useDeprecatedConstants ? Type::STRING : Types::STRING)
325333
->setNotnull(true);
326-
$table->addColumn('created_at', Type::DATETIME)
334+
$table->addColumn('created_at', !$useDeprecatedConstants ? Type::DATETIME : Types::DATETIME_MUTABLE)
327335
->setNotnull(true);
328-
$table->addColumn('available_at', Type::DATETIME)
336+
$table->addColumn('available_at', !$useDeprecatedConstants ? Type::DATETIME : Types::DATETIME_MUTABLE)
329337
->setNotnull(true);
330-
$table->addColumn('delivered_at', Type::DATETIME)
338+
$table->addColumn('delivered_at', !$useDeprecatedConstants ? Type::DATETIME : Types::DATETIME_MUTABLE)
331339
->setNotnull(false);
332340
$table->setPrimaryKey(['id']);
333341
$table->addIndex(['queue_name']);

0 commit comments

Comments
 (0)
0