-
-
Notifications
You must be signed in to change notification settings - Fork 261
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
spl_object_id() expects parameter 1 to be object, string given in PHP 7.4 and version AuditBundle 1.12 #623
Comments
It seems related to I think we're passing the old data and the new data so without any more information, I would think you are passing |
I suspect that array_merge in the LogRevisionsListener::postUpdate() function (https://github.com/sonata-project/EntityAuditBundle/blob/1.12.0/src/EventListener/LogRevisionsListener.php#L246) provides an unexpected result for those entities which primary keys include a foreign key/relationship to another entity (which is our case with ProductCompany entity) i have dumped data of each of the three arrays that are being merged there: $this->getOriginalEntityData($em, $entity) $uow->getEntityIdentifier($entity), $this->getManyToManyRelations($em, $entity) values from $uow->getEntityIdentifier($entity) override those from $this->getOriginalEntityData($em, $entity), so the resulting array is in which the 'product' and 'company' entities have been replaced with only their ids later this causes the 'spl_object_id() expects parameter 1 to be object, string given' TypeError in the LogRevisionsListener::saveRevisionEntityData() function (https://github.com/sonata-project/EntityAuditBundle/blob/1.12.0/src/EventListener/LogRevisionsListener.php#L522) where function \Doctrine\ORM\UnitOfWork::isInIdentityMap($entity) recieves 'PN0002624' in the $entity parameter, instead of the expected Product entity (the same would then happen for the 'PSP' string in place of the expected Company entity) i think we are saving our entities correctly and this is an oversight in EntityAuditBundle related to primary keys composed of foreign keys (similar to #502) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Environment
Sonata packages
show
Symfony packages
show
PHP version
Subject
Auditing entity which uses foreign key as primary key throws exception when entity manager flushes.
Minimal repository with the bug
Steps to reproduce
When entity manager flushes and exception is thrown: spl_object_id() expects parameter 1 to be object, string given
Table product:
Table product_company
Expected results
Actual results
The text was updated successfully, but these errors were encountered: