Skip to content

Deprecate array and object column types #5470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ awareness about deprecated code.

# Upgrade to 3.4

## Deprecated `array` and `object` column types.

The `array` and `object` column types have been deprecated since they use PHP built-in serialization. Without additional
configuration, which the API of these types doesn't allow, the usage of built-in serialization may lead to
security issues.

The following classes and constants have been deprecated:
- `ArrayType`,
- `ObjectType`,
- `Types::ARRAY`,
- `Types::OBJECT`.

Use JSON for storing unstructured data.

## Deprecated `Driver::getSchemaManager()`.

The `Driver::getSchemaManager()` method has been deprecated. Use `AbstractPlatform::createSchemaManager()` instead.
Expand Down
16 changes: 16 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,24 @@
-->
<referencedClass name="Doctrine\DBAL\Schema\Visitor\AbstractVisitor"/>
<referencedClass name="Doctrine\DBAL\Schema\Visitor\Visitor"/>
<!--
TODO: remove in 4.0.0
-->
<referencedClass name="Doctrine\DBAL\Types\ArrayType"/>
<referencedClass name="Doctrine\DBAL\Types\ObjectType"/>
</errorLevel>
</DeprecatedClass>
<DeprecatedConstant>
<errorLevel type="suppress">
<!--
TODO: remove in 4.0.0
-->
<file name="src/Types/ArrayType.php"/>
<file name="src/Types/ObjectType.php"/>
<file name="src/Types/Type.php"/>
<file name="tests/Schema/ComparatorTest.php"/>
</errorLevel>
</DeprecatedConstant>
<DeprecatedInterface>
<errorLevel type="suppress">
<!--
Expand Down
2 changes: 2 additions & 0 deletions src/Types/ArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

/**
* Type that maps a PHP array to a clob SQL type.
*
* @deprecated Use {@link JsonType} instead.
*/
class ArrayType extends Type
{
Expand Down
2 changes: 2 additions & 0 deletions src/Types/ObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

/**
* Type that maps a PHP object to a clob SQL type.
*
* @deprecated Use {@link JsonType} instead.
*/
class ObjectType extends Type
{
Expand Down
25 changes: 17 additions & 8 deletions src/Types/Types.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
*/
final class Types
{
public const ARRAY = 'array';
/**
* @deprecated Use {@link Types::JSON} instead.
*/
public const ARRAY = 'array';

public const ASCII_STRING = 'ascii_string';
public const BIGINT = 'bigint';
public const BINARY = 'binary';
Expand All @@ -27,13 +31,18 @@ final class Types
public const GUID = 'guid';
public const INTEGER = 'integer';
public const JSON = 'json';
public const OBJECT = 'object';
public const SIMPLE_ARRAY = 'simple_array';
public const SMALLINT = 'smallint';
public const STRING = 'string';
public const TEXT = 'text';
public const TIME_MUTABLE = 'time';
public const TIME_IMMUTABLE = 'time_immutable';

/**
* @deprecated Use {@link Types::JSON} instead.
*/
public const OBJECT = 'object';

public const SIMPLE_ARRAY = 'simple_array';
public const SMALLINT = 'smallint';
public const STRING = 'string';
public const TEXT = 'text';
public const TIME_MUTABLE = 'time';
public const TIME_IMMUTABLE = 'time_immutable';

/**
* @codeCoverageIgnore
Expand Down