auditor icon indicating copy to clipboard operation
auditor copied to clipboard

Version 3.3.4 throws ReflectionException

Open stijnh92 opened this issue 6 months ago • 0 comments

Q A
auditor version 3.3.4
PHP version 8.3.24
Database MySQL

Summary

After upgrading damienharper/auditor bundle to version 3.3.4, I now get exceptions related to reflection when it tries to insert a new audit entry.

ReflectionException: Given object is not an instance of the class this property was declared in

/app/vendor/doctrine/persistence/src/Persistence/Reflection/TypedNoDefaultReflectionPropertyBase.php:33
/app/vendor/damienharper/auditor/src/Provider/Doctrine/Persistence/Helper/DoctrineHelper.php:115
/app/vendor/damienharper/auditor/src/Provider/Doctrine/Auditing/Transaction/AuditTrait.php:62
/app/vendor/damienharper/auditor/src/Provider/Doctrine/Auditing/Transaction/AuditTrait.php:245
/app/vendor/damienharper/auditor/src/Provider/Doctrine/Auditing/Transaction/AuditTrait.php:173
/app/vendor/damienharper/auditor/src/Provider/Doctrine/Auditing/Transaction/TransactionProcessor.php:60
/app/vendor/damienharper/auditor/src/Provider/Doctrine/Auditing/Transaction/TransactionProcessor.php:137
/app/vendor/damienharper/auditor/src/Provider/Doctrine/Auditing/Transaction/TransactionProcessor.php:38
/app/vendor/damienharper/auditor/src/Provider/Doctrine/Auditing/Transaction/TransactionManager.php:32
/app/vendor/damienharper/auditor/src/Provider/Doctrine/Auditing/Event/DoctrineSubscriber.php:56
/app/vendor/damienharper/auditor/src/Provider/Doctrine/Auditing/DBAL/Middleware/AuditorConnection.php:24
/app/vendor/doctrine/dbal/src/Connection.php:1502
/app/vendor/doctrine/dbal/src/Connection.php:1454
/app/vendor/doctrine/orm/src/UnitOfWork.php:477
/app/vendor/doctrine/orm/src/EntityManager.php:414

Current behavior

When it wants to create a new entry in the audit table, this ReflectionException pops up.

How to reproduce

The entity that is audited has a Many2one as its identifier. I think it's related to that because this issue only appears on this entity, and not on any other.

It looks something like this:

class Bar
{
    #[ORM\Id]
    #[ORM\ManyToOne(targetEntity: Foo::class, inversedBy: 'bars')]
    #[ORM\JoinColumn(name: 'foo_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
    private Foo $foo;

    #[ORM\Column(name: 'username', type: 'string', length: 255, nullable: true)]
    private ?string $username = null;

    ....
}

Expected behavior

On version 3.3.3 it works fine. I just downgraded and everything is working again.

stijnh92 avatar Oct 07 '25 10:10 stijnh92