You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After updating, I get an error saying that an entity was not found in the chain configured namespaces. This seems to be because I have two entity managers in doctrine.yml that each have separate mappings. These entity managers are also registered as auditing providers. Yet in the code in Provider/Doctrine/Configuration.php all entities are processed for each auditing service, which cannot possibly work.
foreach ($auditingServices as $auditingService) {
$entityManager = $auditingService->getEntityManager();
$platform = $entityManager->getConnection()->getDatabasePlatform();
...
\assert(null !== $this->entities);
foreach ($this->entities as $entity => $config) {
//Below line fails because an entity is not mapped for the current auditingService/entityManager
$meta = $entityManager->getClassMetadata(DoctrineHelper::getRealClassName($entity));
Current behavior
Loading entities crashes and auditing changes therefore does not work
How to reproduce
Have two entity managers setup in doctrine.yml. Each having different entity mappings. Register the entity managers are auditingProviders and try to edit some entities. It will crash on flush because it is trying to load an entity metadata with an entityManager it is not mapped for.
Expected behavior
It should load entities that are mapped to the relevant entityManager, and skip an entityManager if it does not have the correct mapping.
As a workaround I can register every entity to every entityManager, but that is sloppy and bloats the code
The text was updated successfully, but these errors were encountered:
Same issue here with auditor-bundle 6.2, php 8.2, on mysql.
For whacky reasons we have two entity mangers, where the second one only maps a subset of the entities of the first one.
So, as an example, default_entity_manager has everything unter App\Entity, while foo_entity_manager only maps App\Entity\Foo.
This worked with auditor-bundle 5.2 which seems to only care about the default, but for some reason also gets events (and therefor write audits) for flushes on the foo manager.
With 6.2 I needed to add foo_entity_manager to the auditing_services config, and started to get a crash at the same line as mentioned above. Same problem: it tries to map all entities via ll entity managers, which, afaict, cannot work.
One hacky fix could be to add a try { ... } catch (MappingException) { continue; } around that line, to skip handling an entity if its not mapped in that EM, but implementing it that naive will swallow real errors and the performance is certainly terrible, because unmapped entities will never hit the cache afaik.
I currently do not have a good solution. As far as I can tell there is not way to ask the doctrine configuration if a given entity class is mapped for an entity manager.
One posible way to to "properly" handle this, could be to keep the split between the auditing services consistend over the whole metadata/configuration system, so the entity managers are always separate and a single transaction event is only looking at its own entity manager (which is part of doctrines event object). But I have not looked at enough of the code to be able to say if thats feasible, its certainly looks like it would be a larger refactoring.
Uh oh!
There was an error while loading. Please reload this page.
auditor-bundle
versionSummary
After updating, I get an error saying that an entity was not found in the chain configured namespaces. This seems to be because I have two entity managers in doctrine.yml that each have separate mappings. These entity managers are also registered as auditing providers. Yet in the code in
Provider/Doctrine/Configuration.php
all entities are processed for each auditing service, which cannot possibly work.Doctrine.yml:
Current behavior
Loading entities crashes and auditing changes therefore does not work
How to reproduce
Have two entity managers setup in doctrine.yml. Each having different entity mappings. Register the entity managers are auditingProviders and try to edit some entities. It will crash on flush because it is trying to load an entity metadata with an entityManager it is not mapped for.
Expected behavior
It should load entities that are mapped to the relevant entityManager, and skip an entityManager if it does not have the correct mapping.
As a workaround I can register every entity to every entityManager, but that is sloppy and bloats the code
The text was updated successfully, but these errors were encountered: