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