mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Revert "Migrated deprecated doctrine event subsrcibers"
For some very very weird reasoning this cause issues with the ObjectNormalizer, which does not get an an serializer injected anymore. When the EventLoggerSubscriber is a doctrine subscriber it seems that the serializer service is initialized (as its requested in constructor but not used) and later injected into the object normalizer. When its an listener, this does not work anymore.
This commit is contained in:
parent
d7383539ba
commit
b5721dcfd0
3 changed files with 24 additions and 13 deletions
|
@ -76,7 +76,7 @@ services:
|
|||
# Only the event classes specified here are saved to DB (set to []) to log all events
|
||||
$whitelist: []
|
||||
|
||||
App\EventListener\LogSystem\EventLoggerListener:
|
||||
App\EventSubscriber\LogSystem\EventLoggerSubscriber:
|
||||
arguments:
|
||||
$save_changed_fields: '%env(bool:HISTORY_SAVE_CHANGED_FIELDS)%'
|
||||
$save_changed_data: '%env(bool:HISTORY_SAVE_CHANGED_DATA)%'
|
||||
|
@ -85,7 +85,7 @@ services:
|
|||
tags:
|
||||
- { name: 'doctrine.event_subscriber' }
|
||||
|
||||
App\EventListener\LogSystem\LogDBMigrationListener:
|
||||
App\EventSubscriber\LogSystem\LogDBMigrationSubscriber:
|
||||
tags:
|
||||
- { name: 'doctrine.event_subscriber' }
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\EventListener\LogSystem;
|
||||
namespace App\EventSubscriber\LogSystem;
|
||||
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Base\AbstractDBElement;
|
||||
|
@ -38,7 +38,7 @@ use App\Entity\UserSystem\User;
|
|||
use App\Services\LogSystem\EventCommentHelper;
|
||||
use App\Services\LogSystem\EventLogger;
|
||||
use App\Services\LogSystem\EventUndoHelper;
|
||||
use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener;
|
||||
use Doctrine\Common\EventSubscriber;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Event\OnFlushEventArgs;
|
||||
use Doctrine\ORM\Event\PostFlushEventArgs;
|
||||
|
@ -50,10 +50,7 @@ use Symfony\Component\Serializer\SerializerInterface;
|
|||
/**
|
||||
* This event subscriber writes to the event log when entities are changed, removed, created.
|
||||
*/
|
||||
#[AsDoctrineListener(Events::onFlush)]
|
||||
#[AsDoctrineListener(Events::postPersist)]
|
||||
#[AsDoctrineListener(Events::postFlush)]
|
||||
class EventLoggerListener
|
||||
class EventLoggerSubscriber implements EventSubscriber
|
||||
{
|
||||
/**
|
||||
* @var array The given fields will not be saved, because they contain sensitive information
|
||||
|
@ -190,6 +187,14 @@ class EventLoggerListener
|
|||
return true;
|
||||
}
|
||||
|
||||
public function getSubscribedEvents(): array
|
||||
{
|
||||
return[
|
||||
Events::onFlush,
|
||||
Events::postPersist,
|
||||
Events::postFlush,
|
||||
];
|
||||
}
|
||||
|
||||
protected function logElementDeleted(AbstractDBElement $entity, EntityManagerInterface $em): void
|
||||
{
|
|
@ -20,11 +20,11 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\EventListener\LogSystem;
|
||||
namespace App\EventSubscriber\LogSystem;
|
||||
|
||||
use App\Entity\LogSystem\DatabaseUpdatedLogEntry;
|
||||
use App\Services\LogSystem\EventLogger;
|
||||
use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener;
|
||||
use Doctrine\Common\EventSubscriber;
|
||||
use Doctrine\Migrations\DependencyFactory;
|
||||
use Doctrine\Migrations\Event\MigrationsEventArgs;
|
||||
use Doctrine\Migrations\Events;
|
||||
|
@ -32,9 +32,7 @@ use Doctrine\Migrations\Events;
|
|||
/**
|
||||
* This subscriber logs databaseMigrations to Event log.
|
||||
*/
|
||||
#[AsDoctrineListener(Events::onMigrationsMigrated)]
|
||||
#[AsDoctrineListener(Events::onMigrationsMigrating)]
|
||||
class LogDBMigrationListener
|
||||
class LogDBMigrationSubscriber implements EventSubscriber
|
||||
{
|
||||
protected ?string $old_version = null;
|
||||
protected ?string $new_version = null;
|
||||
|
@ -78,4 +76,12 @@ class LogDBMigrationListener
|
|||
$this->old_version = (string) $aliasResolver->resolveVersionAlias('current');
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
Events::onMigrationsMigrated,
|
||||
Events::onMigrationsMigrating,
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue