Commit acefb080 authored by Oliver Hader's avatar Oliver Hader Committed by Oliver Hader
Browse files

[TASK] Avoid using deprecated Doctrine types

Issue #89592 upgraded Doctrine to v2.10.0 - usages of deprecated
`TYPE::*` constants have not been adjusted (see doctrine/dbal
changelog https://github.com/doctrine/dbal/releases/tag/v2.10.0).

Resolves: #89592
Releases: master
Change-Id: Ic7aacf5041f22016876ed9daae4d167b0d15c493
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62249


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Manuel Selbach's avatarManuel Selbach <manuel_selbach@yahoo.de>
Tested-by: Oliver Hader's avatarOliver Hader <oliver.hader@typo3.org>
Reviewed-by: Manuel Selbach's avatarManuel Selbach <manuel_selbach@yahoo.de>
Reviewed-by: Oliver Hader's avatarOliver Hader <oliver.hader@typo3.org>
parent 8c0993ed
...@@ -22,6 +22,7 @@ use Doctrine\DBAL\Schema\Column; ...@@ -22,6 +22,7 @@ use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Schema\Parser\AST\CreateColumnDefinitionItem; use TYPO3\CMS\Core\Database\Schema\Parser\AST\CreateColumnDefinitionItem;
use TYPO3\CMS\Core\Database\Schema\Parser\AST\CreateForeignKeyDefinitionItem; use TYPO3\CMS\Core\Database\Schema\Parser\AST\CreateForeignKeyDefinitionItem;
...@@ -301,57 +302,57 @@ class TableBuilder ...@@ -301,57 +302,57 @@ class TableBuilder
case DataType\TinyIntDataType::class: case DataType\TinyIntDataType::class:
// TINYINT is MySQL specific and mapped to a standard SMALLINT // TINYINT is MySQL specific and mapped to a standard SMALLINT
case DataType\SmallIntDataType::class: case DataType\SmallIntDataType::class:
$doctrineType = Type::SMALLINT; $doctrineType = Types::SMALLINT;
break; break;
case DataType\MediumIntDataType::class: case DataType\MediumIntDataType::class:
// MEDIUMINT is MySQL specific and mapped to a standard INT // MEDIUMINT is MySQL specific and mapped to a standard INT
case DataType\IntegerDataType::class: case DataType\IntegerDataType::class:
$doctrineType = Type::INTEGER; $doctrineType = Types::INTEGER;
break; break;
case DataType\BigIntDataType::class: case DataType\BigIntDataType::class:
$doctrineType = Type::BIGINT; $doctrineType = Types::BIGINT;
break; break;
case DataType\BinaryDataType::class: case DataType\BinaryDataType::class:
case DataType\VarBinaryDataType::class: case DataType\VarBinaryDataType::class:
// CHAR/VARCHAR is determined by "fixed" column property // CHAR/VARCHAR is determined by "fixed" column property
$doctrineType = Type::BINARY; $doctrineType = Types::BINARY;
break; break;
case DataType\TinyBlobDataType::class: case DataType\TinyBlobDataType::class:
case DataType\MediumBlobDataType::class: case DataType\MediumBlobDataType::class:
case DataType\BlobDataType::class: case DataType\BlobDataType::class:
case DataType\LongBlobDataType::class: case DataType\LongBlobDataType::class:
// Actual field type is determined by field length // Actual field type is determined by field length
$doctrineType = Type::BLOB; $doctrineType = Types::BLOB;
break; break;
case DataType\DateDataType::class: case DataType\DateDataType::class:
$doctrineType = Type::DATE; $doctrineType = Types::DATE_MUTABLE;
break; break;
case DataType\TimestampDataType::class: case DataType\TimestampDataType::class:
case DataType\DateTimeDataType::class: case DataType\DateTimeDataType::class:
// TIMESTAMP or DATETIME are determined by "version" column property // TIMESTAMP or DATETIME are determined by "version" column property
$doctrineType = Type::DATETIME; $doctrineType = Types::DATETIME_MUTABLE;
break; break;
case DataType\NumericDataType::class: case DataType\NumericDataType::class:
case DataType\DecimalDataType::class: case DataType\DecimalDataType::class:
$doctrineType = Type::DECIMAL; $doctrineType = Types::DECIMAL;
break; break;
case DataType\RealDataType::class: case DataType\RealDataType::class:
case DataType\FloatDataType::class: case DataType\FloatDataType::class:
case DataType\DoubleDataType::class: case DataType\DoubleDataType::class:
$doctrineType = Type::FLOAT; $doctrineType = Types::FLOAT;
break; break;
case DataType\TimeDataType::class: case DataType\TimeDataType::class:
$doctrineType = Type::TIME; $doctrineType = Types::TIME_MUTABLE;
break; break;
case DataType\TinyTextDataType::class: case DataType\TinyTextDataType::class:
case DataType\MediumTextDataType::class: case DataType\MediumTextDataType::class:
case DataType\TextDataType::class: case DataType\TextDataType::class:
case DataType\LongTextDataType::class: case DataType\LongTextDataType::class:
$doctrineType = Type::TEXT; $doctrineType = Types::TEXT;
break; break;
case DataType\CharDataType::class: case DataType\CharDataType::class:
case DataType\VarCharDataType::class: case DataType\VarCharDataType::class:
$doctrineType = Type::STRING; $doctrineType = Types::STRING;
break; break;
case DataType\EnumDataType::class: case DataType\EnumDataType::class:
$doctrineType = EnumType::TYPE; $doctrineType = EnumType::TYPE;
...@@ -361,7 +362,7 @@ class TableBuilder ...@@ -361,7 +362,7 @@ class TableBuilder
break; break;
case DataType\JsonDataType::class: case DataType\JsonDataType::class:
// JSON is not supported in Doctrine 2.5, mapping to the more generic TEXT type // JSON is not supported in Doctrine 2.5, mapping to the more generic TEXT type
$doctrineType = SetType::TEXT; $doctrineType = Types::TEXT;
break; break;
case DataType\YearDataType::class: case DataType\YearDataType::class:
// The YEAR data type is MySQL specific and offers little to no benefit. // The YEAR data type is MySQL specific and offers little to no benefit.
...@@ -370,7 +371,7 @@ class TableBuilder ...@@ -370,7 +371,7 @@ class TableBuilder
// application and for all other accounts it's an integer with a valid // application and for all other accounts it's an integer with a valid
// range of 1901 to 2155. // range of 1901 to 2155.
// Using a SMALLINT covers the value range and ensures database compatibility. // Using a SMALLINT covers the value range and ensures database compatibility.
$doctrineType = SetType::SMALLINT; $doctrineType = Types::SMALLINT;
break; break;
default: default:
throw new \RuntimeException( throw new \RuntimeException(
......
...@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Lowlevel\Integrity; ...@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Lowlevel\Integrity;
* The TYPO3 project - inspiring people to share! * The TYPO3 project - inspiring people to share!
*/ */
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types;
use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\ConnectionPool;
...@@ -451,7 +451,7 @@ class DatabaseIntegrityCheck ...@@ -451,7 +451,7 @@ class DatabaseIntegrityCheck
$fieldType = $column->getType()->getName(); $fieldType = $column->getType()->getName();
if (in_array( if (in_array(
$fieldType, $fieldType,
[Type::BIGINT, Type::INTEGER, Type::SMALLINT, Type::DECIMAL, Type::FLOAT], [Types::BIGINT, Types::INTEGER, Types::SMALLINT, Types::DECIMAL, Types::FLOAT],
true true
)) { )) {
$whereClause[] = $queryBuilder->expr()->andX( $whereClause[] = $queryBuilder->expr()->andX(
...@@ -461,7 +461,7 @@ class DatabaseIntegrityCheck ...@@ -461,7 +461,7 @@ class DatabaseIntegrityCheck
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
) )
); );
} elseif (in_array($fieldType, [Type::STRING, Type::TEXT], true)) { } elseif (in_array($fieldType, [Types::STRING, Types::TEXT], true)) {
$whereClause[] = $queryBuilder->expr()->andX( $whereClause[] = $queryBuilder->expr()->andX(
$queryBuilder->expr()->isNotNull($fieldName), $queryBuilder->expr()->isNotNull($fieldName),
$queryBuilder->expr()->neq( $queryBuilder->expr()->neq(
...@@ -469,7 +469,7 @@ class DatabaseIntegrityCheck ...@@ -469,7 +469,7 @@ class DatabaseIntegrityCheck
$queryBuilder->createNamedParameter('', \PDO::PARAM_STR) $queryBuilder->createNamedParameter('', \PDO::PARAM_STR)
) )
); );
} elseif ($fieldType === Type::BLOB) { } elseif ($fieldType === Types::BLOB) {
$whereClause[] = $queryBuilder->expr()->andX( $whereClause[] = $queryBuilder->expr()->andX(
$queryBuilder->expr()->isNotNull($fieldName), $queryBuilder->expr()->isNotNull($fieldName),
$queryBuilder->expr() $queryBuilder->expr()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment