Merge pull request #6171 from wallabag/fix/json-array-dbal-type

Properly handle `json_array` type removal
This commit is contained in:
Jérémy Benoist
2022-12-22 16:29:53 +01:00
committed by GitHub
6 changed files with 114 additions and 4 deletions

View File

@ -0,0 +1,46 @@
<?php
namespace Wallabag\CoreBundle\Doctrine;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\JsonType;
/**
* Removed type from DBAL in v3.
* The type is no more used, but we must keep it in order to avoid error during migrations.
*
* @see https://github.com/doctrine/dbal/commit/6ed32a9a941acf0cb6ad384b84deb8df68ca83f8
* @see https://dunglas.dev/2022/01/json-columns-and-doctrine-dbal-3-upgrade/
*/
class JsonArrayType extends JsonType
{
/**
* {@inheritdoc}
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if (null === $value || '' === $value) {
return [];
}
$value = \is_resource($value) ? stream_get_contents($value) : $value;
return json_decode($value, true);
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'json_array';
}
/**
* {@inheritdoc}
*/
public function requiresSQLCommentHint(AbstractPlatform $platform)
{
return true;
}
}

View File

@ -128,6 +128,8 @@ class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorI
private $googleAuthenticatorSecret;
/**
* @var array
*
* @ORM\Column(type="json", nullable=true)
*/
private $backupCodes;