From 9d104aa355a7fdd0cb6507554cf4063ab75e78aa Mon Sep 17 00:00:00 2001 From: Nattfarinn Date: Wed, 17 Apr 2024 09:41:46 +0200 Subject: [PATCH] fix: register new subscriber in test setup factory --- .../settings/tests/integration_legacy.yml | 1 + .../Mapper/ResolveVirtualFieldSubscriber.php | 40 +++++++++++-------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/eZ/Publish/Core/settings/tests/integration_legacy.yml b/eZ/Publish/Core/settings/tests/integration_legacy.yml index d656f1b935..c2a96cec18 100644 --- a/eZ/Publish/Core/settings/tests/integration_legacy.yml +++ b/eZ/Publish/Core/settings/tests/integration_legacy.yml @@ -33,6 +33,7 @@ services: - ['addSubscriber', ['@eZ\Publish\Core\Search\Common\EventSubscriber\SectionEventSubscriber']] - ['addSubscriber', ['@eZ\Publish\Core\Search\Common\EventSubscriber\TrashEventSubscriber']] - ['addSubscriber', ['@eZ\Publish\Core\Search\Common\EventSubscriber\UserEventSubscriber']] + - ['addSubscriber', ['@Ibexa\Core\Persistence\Legacy\Content\Mapper\ResolveVirtualFieldSubscriber']] Doctrine\Common\EventManager: ~ diff --git a/src/lib/Persistence/Legacy/Content/Mapper/ResolveVirtualFieldSubscriber.php b/src/lib/Persistence/Legacy/Content/Mapper/ResolveVirtualFieldSubscriber.php index c04fe5dc9e..c5d1d80cdb 100644 --- a/src/lib/Persistence/Legacy/Content/Mapper/ResolveVirtualFieldSubscriber.php +++ b/src/lib/Persistence/Legacy/Content/Mapper/ResolveVirtualFieldSubscriber.php @@ -103,26 +103,34 @@ public function persistExternalStorageField(ResolveMissingFieldEvent $event): vo $this->getDefaultStorageValue() ); - $result = $storage->storeFieldData( - $content->versionInfo, - $field, - $event->getContext() - ); - - if ($result === true) { - $storageValue = new StorageFieldValue(); - $converter = $this->converterRegistry->getConverter($fieldDefinition->fieldType); - $converter->toStorageValue( - $field->value, - $storageValue - ); - - $this->contentGateway->updateField( + if ($field->value->data !== null) { + $result = $storage->storeFieldData( + $content->versionInfo, $field, - $storageValue + [] ); + + if ($result === true) { + $storageValue = new StorageFieldValue(); + $converter = $this->converterRegistry->getConverter($fieldDefinition->fieldType); + $converter->toStorageValue( + $field->value, + $storageValue + ); + + $this->contentGateway->updateField( + $field, + $storageValue + ); + } } + $storage->getFieldData( + $content->versionInfo, + $field, + [] + ); + $event->setField($field); }