Skip to content
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

Unable to save changes to array fields #11

Closed
codedmonkey opened this issue Jul 6, 2018 · 7 comments
Closed

Unable to save changes to array fields #11

codedmonkey opened this issue Jul 6, 2018 · 7 comments
Labels
bug Something isn't working

Comments

@codedmonkey
Copy link

codedmonkey commented Jul 6, 2018

Hi, thanks for the great bundle. It seems that after a recent change we can't save changes to arrays and JSON array fields as it throws the following error:

In ArrayType.php line 65:

  [Symfony\Component\Debug\Exception\ContextErrorException]
  Warning: unserialize() expects parameter 1 to be string, array given


Exception trace:
 Doctrine\DBAL\Types\ArrayType->convertToPHPValue() at D:\project\vendor\damienharper\doctrine-audit-bundle\src\DoctrineAuditBundle\EventSubscriber\AuditSubscriber.php:458
 DH\DoctrineAuditBundle\EventSubscriber\AuditSubscriber->value() at D:\project\vendor\damienharper\doctrine-audit-bundle\src\DoctrineAuditBundle\EventSubscriber\AuditSubscriber.php:383
 DH\DoctrineAuditBundle\EventSubscriber\AuditSubscriber->diff() at D:\project\vendor\damienharper\doctrine-audit-bundle\src\DoctrineAuditBundle\EventSubscriber\AuditSubscriber.php:190
 DH\DoctrineAuditBundle\EventSubscriber\AuditSubscriber->insert() at D:\project\vendor\damienharper\doctrine-audit-bundle\src\DoctrineAuditBundle\EventSubscriber\AuditSubscriber.php:146
 DH\DoctrineAuditBundle\EventSubscriber\AuditSubscriber->flush() at D:\project\vendor\damienharper\doctrine-audit-bundle\src\DoctrineAuditBundle\EventSubscriber\AuditSubscriber.php:56
 DH\DoctrineAuditBundle\EventSubscriber\AuditSubscriber->DH\DoctrineAuditBundle\EventSubscriber\{closure}() at n/a:n/a
 call_user_func() at D:\project\vendor\damienharper\doctrine-audit-bundle\src\DoctrineAuditBundle\DBAL\AuditLogger.php:26
 DH\DoctrineAuditBundle\DBAL\AuditLogger->startQuery() at D:\project\vendor\doctrine\dbal\lib\Doctrine\DBAL\Logging\LoggerChain.php:54
 Doctrine\DBAL\Logging\LoggerChain->startQuery() at D:\project\vendor\doctrine\dbal\lib\Doctrine\DBAL\Connection.php:1311
 Doctrine\DBAL\Connection->commit() at D:\project\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php:237
 Doctrine\ORM\EntityManager->transactional() at D:\project\vendor\doctrine\data-fixtures\lib\Doctrine\Common\DataFixtures\Executor\ORMExecutor.php:73
 Doctrine\Common\DataFixtures\Executor\ORMExecutor->execute() at D:\project\vendor\doctrine\doctrine-fixtures-bundle\Command\LoadDataFixturesDoctrineCommand.php:105
 Doctrine\Bundle\FixturesBundle\Command\LoadDataFixturesDoctrineCommand->execute() at D:\project\vendor\symfony\console\Command\Command.php:251
 Symfony\Component\Console\Command\Command->run() at D:\project\vendor\symfony\console\Application.php:964
 Symfony\Component\Console\Application->doRunCommand() at D:\project\vendor\symfony\framework-bundle\Console\Application.php:86
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at D:\project\vendor\symfony\console\Application.php:248
 Symfony\Component\Console\Application->doRun() at D:\project\vendor\symfony\framework-bundle\Console\Application.php:74
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at D:\project\vendor\symfony\console\Application.php:148
 Symfony\Component\Console\Application->run() at D:\project\bin\console:39

I looked at the convertToPHPValue method and it doesn't seem to be particular useful in this case, as it seems to expect the given value to come directly from the database, not from the entity, hopefully that helps.

Thanks!

@codedmonkey codedmonkey changed the title Unable to save changes to JSON field Unable to save changes to array fields Jul 6, 2018
@m-rsmn
Copy link

m-rsmn commented Jul 13, 2018

Facing the same issue at the moment, in my case, I'm trying to save multiple roles to a user, which are an array, and I'm running in to the same issue.

Reverting back to the 1.0.6 release seems to have fixed the issue at the moment.

From going through the commits for that release, looks like this change is the culprit

@DamienHarper
Copy link
Owner

@codedmonkey @dajoykill sorry for this late reply, you're right, I confirm the issues you're running into.
As @dajoykill says, you can downgrade to 1.0.6 while I'm working a a fix. Thanks for your patience.

DamienHarper added a commit that referenced this issue Jul 19, 2018
@DamienHarper
Copy link
Owner

@codedmonkey and @dajoykill: I pushed a fix on the master branch, can you confirm it fixes the issue for you?

@codedmonkey
Copy link
Author

Yes seems to work great! Many thanks.

@m-rsmn
Copy link

m-rsmn commented Jul 23, 2018

@DamienHarper I also confirm, the fix works. I suppose you'll push this in to a new release eventually?

@DamienHarper
Copy link
Owner

@dajoykill sure, I'll do it shortly

@DamienHarper
Copy link
Owner

1.0.8 is released fixing these issues.

@DamienHarper DamienHarper added the bug Something isn't working label Sep 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants