Problem/Motivation

It is not possible to identify the author of the content after deploying it between workspaces of the same environment, because it is being replaced by the "default" user from the replication settings.

Expected behaviour

Keep the original author of the content when deploy is happening between 2 workspaces of the same environment.

Proposed resolution

Based on context, decide whether to change the user when the entity normalizes or not.

CommentFileSizeAuthor
#4 interdiff-3027602-4.txt677 bytesaxicdv
#4 3027602-4.patch690 bytesaxicdv
#2 3027602-2.patch862 bytesaxicdv

Comments

axicdv created an issue. See original summary.

axicdv’s picture

Status: Active » Needs review
StatusFileSize
new862 bytes
l0ke’s picture

I would give a try to another approach

+++ b/src/Normalizer/EntityReferenceItemNormalizer.php
@@ -34,8 +34,9 @@ class EntityReferenceItemNormalizer extends FieldItemNormalizer {
+    if ($target_type === 'user' && empty($context['is_internal_replication'])) {
       $taget_id = \Drupal::service('replication.users_mapping')->getUidFromConfig();
     }

Do not force uid from settings on Normalization.
Instead, handle it like any other entity reference but add a similar condition on denormalization and check if the user with given UUID exists
- if yes then we can keep the original reference properly
- if no set value from \Drupal::service('replication.users_mapping')->getUidFromConfig()

This approach will also mean that #3027599: Workspace. Internal replication. Do not override the author of the content is not longer needed.

axicdv’s picture

Similar condition on denormalization exist.(UsersMapping::mapReferenceField())
Force uid from settings on Normalization deleted.

l0ke’s picture

Status: Needs review » Reviewed & tested by the community
knyshuk.vova’s picture

The patch looks good and applies successfully. +1 for RTBC.

  • jeqq committed 0edf626 on 8.x-1.x authored by axicdv
    Issue #3027602 by axicdv, l0ke: Replication. Internal replication. Do...
jeqq’s picture

Status: Reviewed & tested by the community » Fixed

Thank you!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.