Skip to content

Commit 8c812c8

Browse files
Merge branch '4.4' into 5.0
* 4.4: minor #35833 [FrameworkBundle] Add missing items in the unused tag pass whitelist (fabpot) [HttpClient][DX] Add URL context to JsonException messages [Routing] Improve localized routes performances [4.4][DoctrineBridge] Use new Types::* constants and support new json type [Validator] Add missing translations [Messenger] Use Doctrine DBAL new Types::* constants
2 parents 290b589 + 7efb10d commit 8c812c8

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

Transport/Doctrine/Connection.php

Lines changed: 26 additions & 10 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

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

57+
private static $useDeprecatedConstants;
58+
5659
public function __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 ?? new SingleDatabaseSynchronizer($this->driverConnection);
6164
$this->autoSetup = $this->configuration['auto_setup'];
65+
66+
if (null === self::$useDeprecatedConstants) {
67+
self::$useDeprecatedConstants = !class_exists(Types::class);
68+
}
6269
}
6370

6471
public function getConfiguration(): array
@@ -125,12 +132,18 @@ public function send(string $body, array $headers, int $delay = 0): string
125132
$this->configuration['queue_name'],
126133
$now,
127134
$availableAt,
128-
], [
135+
], self::$useDeprecatedConstants ? [
129136
null,
130137
null,
131138
null,
132139
Type::DATETIME,
133140
Type::DATETIME,
141+
] : [
142+
null,
143+
null,
144+
null,
145+
Types::DATETIME_MUTABLE,
146+
Types::DATETIME_MUTABLE,
134147
]);
135148

136149
return $this->driverConnection->lastInsertId();
@@ -169,7 +182,7 @@ public function get(): ?array
169182
$now,
170183
$doctrineEnvelope['id'],
171184
], [
172-
Type::DATETIME,
185+
self::$useDeprecatedConstants ? Type::DATETIME : Types::DATETIME_MUTABLE,
173186
]);
174187

175188
$this->driverConnection->commit();
@@ -278,9 +291,12 @@ private function createAvailableMessagesQueryBuilder(): QueryBuilder
278291
$redeliverLimit,
279292
$now,
280293
$this->configuration['queue_name'],
281-
], [
294+
], self::$useDeprecatedConstants ? [
282295
Type::DATETIME,
283296
Type::DATETIME,
297+
] : [
298+
Types::DATETIME_MUTABLE,
299+
Types::DATETIME_MUTABLE,
284300
]);
285301
}
286302

@@ -314,20 +330,20 @@ private function getSchema(): Schema
314330
{
315331
$schema = new Schema([], [], $this->driverConnection->getSchemaManager()->createSchemaConfig());
316332
$table = $schema->createTable($this->configuration['table_name']);
317-
$table->addColumn('id', Type::BIGINT)
333+
$table->addColumn('id', self::$useDeprecatedConstants ? Type::BIGINT : Types::BIGINT)
318334
->setAutoincrement(true)
319335
->setNotnull(true);
320-
$table->addColumn('body', Type::TEXT)
336+
$table->addColumn('body', self::$useDeprecatedConstants ? Type::TEXT : Types::TEXT)
321337
->setNotnull(true);
322-
$table->addColumn('headers', Type::TEXT)
338+
$table->addColumn('headers', self::$useDeprecatedConstants ? Type::TEXT : Types::TEXT)
323339
->setNotnull(true);
324-
$table->addColumn('queue_name', Type::STRING)
340+
$table->addColumn('queue_name', self::$useDeprecatedConstants ? Type::STRING : Types::STRING)
325341
->setNotnull(true);
326-
$table->addColumn('created_at', Type::DATETIME)
342+
$table->addColumn('created_at', self::$useDeprecatedConstants ? Type::DATETIME : Types::DATETIME_MUTABLE)
327343
->setNotnull(true);
328-
$table->addColumn('available_at', Type::DATETIME)
344+
$table->addColumn('available_at', self::$useDeprecatedConstants ? Type::DATETIME : Types::DATETIME_MUTABLE)
329345
->setNotnull(true);
330-
$table->addColumn('delivered_at', Type::DATETIME)
346+
$table->addColumn('delivered_at', self::$useDeprecatedConstants ? Type::DATETIME : Types::DATETIME_MUTABLE)
331347
->setNotnull(false);
332348
$table->setPrimaryKey(['id']);
333349
$table->addIndex(['queue_name']);

0 commit comments

Comments
 (0)