|
20 | 20 | useDoctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer; |
21 | 21 | useDoctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer; |
22 | 22 | useDoctrine\DBAL\Types\Type; |
| 23 | +useDoctrine\DBAL\Types\Types; |
23 | 24 | useSymfony\Component\Messenger\Exception\InvalidArgumentException; |
24 | 25 | useSymfony\Component\Messenger\Exception\TransportException; |
25 | 26 |
|
@@ -53,12 +54,16 @@ class Connection |
53 | 54 | private$schemaSynchronizer; |
54 | 55 | private$autoSetup; |
55 | 56 |
|
| 57 | +privatestatic$useDeprecatedConstants; |
| 58 | + |
56 | 59 | publicfunction__construct(array$configuration,DBALConnection$driverConnection,SchemaSynchronizer$schemaSynchronizer =null) |
57 | 60 | { |
58 | 61 | $this->configuration =array_replace_recursive(self::DEFAULT_OPTIONS,$configuration); |
59 | 62 | $this->driverConnection =$driverConnection; |
60 | 63 | $this->schemaSynchronizer =$schemaSynchronizer ??newSingleDatabaseSynchronizer($this->driverConnection); |
61 | 64 | $this->autoSetup =$this->configuration['auto_setup']; |
| 65 | + |
| 66 | +self::$useDeprecatedConstants =self::$useDeprecatedConstants ?? !class_exists(Types::class); |
62 | 67 | } |
63 | 68 |
|
64 | 69 | publicfunctiongetConfiguration():array |
@@ -125,12 +130,18 @@ public function send(string $body, array $headers, int $delay = 0): string |
125 | 130 | $this->configuration['queue_name'], |
126 | 131 | $now, |
127 | 132 | $availableAt, |
128 | | - ], [ |
| 133 | + ],self::$useDeprecatedConstants ?[ |
129 | 134 | null, |
130 | 135 | null, |
131 | 136 | null, |
132 | 137 | Type::DATETIME, |
133 | 138 | Type::DATETIME, |
| 139 | + ] : [ |
| 140 | +null, |
| 141 | +null, |
| 142 | +null, |
| 143 | + Types::DATETIME_MUTABLE, |
| 144 | + Types::DATETIME_MUTABLE, |
134 | 145 | ]); |
135 | 146 |
|
136 | 147 | return$this->driverConnection->lastInsertId(); |
@@ -168,8 +179,8 @@ public function get(): ?array |
168 | 179 | $this->executeQuery($queryBuilder->getSQL(), [ |
169 | 180 | $now, |
170 | 181 | $doctrineEnvelope['id'], |
171 | | - ],[ |
172 | | - Type::DATETIME, |
| 182 | + ],[ |
| 183 | +self::$useDeprecatedConstants ?Type::DATETIME : Types::DATETIME_MUTABLE, |
173 | 184 | ]); |
174 | 185 |
|
175 | 186 | $this->driverConnection->commit(); |
@@ -278,9 +289,12 @@ private function createAvailableMessagesQueryBuilder(): QueryBuilder |
278 | 289 | $redeliverLimit, |
279 | 290 | $now, |
280 | 291 | $this->configuration['queue_name'], |
281 | | - ], [ |
| 292 | + ],self::$useDeprecatedConstants ?[ |
282 | 293 | Type::DATETIME, |
283 | 294 | Type::DATETIME, |
| 295 | + ] : [ |
| 296 | + Types::DATETIME_MUTABLE, |
| 297 | + Types::DATETIME_MUTABLE, |
284 | 298 | ]); |
285 | 299 | } |
286 | 300 |
|
@@ -314,20 +328,20 @@ private function getSchema(): Schema |
314 | 328 | { |
315 | 329 | $schema =newSchema([], [],$this->driverConnection->getSchemaManager()->createSchemaConfig()); |
316 | 330 | $table =$schema->createTable($this->configuration['table_name']); |
317 | | -$table->addColumn('id', Type::BIGINT) |
| 331 | +$table->addColumn('id',self::$useDeprecatedConstants ?Type::BIGINT : Types::BIGINT) |
318 | 332 | ->setAutoincrement(true) |
319 | 333 | ->setNotnull(true); |
320 | | -$table->addColumn('body', Type::TEXT) |
| 334 | +$table->addColumn('body',self::$useDeprecatedConstants ?Type::TEXT : Types::TEXT) |
321 | 335 | ->setNotnull(true); |
322 | | -$table->addColumn('headers', Type::TEXT) |
| 336 | +$table->addColumn('headers',self::$useDeprecatedConstants ?Type::TEXT : Types::TEXT) |
323 | 337 | ->setNotnull(true); |
324 | | -$table->addColumn('queue_name', Type::STRING) |
| 338 | +$table->addColumn('queue_name',self::$useDeprecatedConstants ?Type::STRING : Types::STRING) |
325 | 339 | ->setNotnull(true); |
326 | | -$table->addColumn('created_at', Type::DATETIME) |
| 340 | +$table->addColumn('created_at',self::$useDeprecatedConstants ?Type::DATETIME : Types::DATETIME_MUTABLE) |
327 | 341 | ->setNotnull(true); |
328 | | -$table->addColumn('available_at', Type::DATETIME) |
| 342 | +$table->addColumn('available_at',self::$useDeprecatedConstants ?Type::DATETIME : Types::DATETIME_MUTABLE) |
329 | 343 | ->setNotnull(true); |
330 | | -$table->addColumn('delivered_at', Type::DATETIME) |
| 344 | +$table->addColumn('delivered_at',self::$useDeprecatedConstants ?Type::DATETIME : Types::DATETIME_MUTABLE) |
331 | 345 | ->setNotnull(false); |
332 | 346 | $table->setPrimaryKey(['id']); |
333 | 347 | $table->addIndex(['queue_name']); |
|