I am using Paragraphs on user accounts. Each paragraph on the given field is unique for each user, but several users may have the same value in one of the paragraph’s fields, and therefore they can be updated via VBO-Edit (later called "VBE"). When I update (add) a paragraph for a single user by simply editing the user (not VBE), the paragraph is assigned a unique PID, and the content is unique to that specific user.

When I use VBE to insert a new paragraph for a group of users, VBE should create a new, unique paragraph for each user, because I need each user’s paragraph to contain values that are unique to that user. In one of the paragraph fields, there is a value that is identical for a group of users — perhaps 20 users. Therefore, I should be able to update (create) paragraphs for those 20 users at once, but it is a requirement that each paragraph’s hidden fields are unique per user (as well as 20 unique PIDs), while the one shared field naturally has the same value for all 20 users.

When I use VBE for this update, VBE creates one paragraph with one PID, which is shared among the 20 users, and the fields that should have been unique per user become shared across all 20 users. This is not correct behavior according to Drupal 11.

---

In a paragraph there is a field, where I can set some statistics.
The paragraph belongs to a field on a user-account.
When I edit the user account and add a paragraph and set the statistic value and save it all, the paragraph get a unique id (pid).
When I use VBE to set the statistic field on at paragraph on several users, there will be one paragraph which is sharet to all the implemented users - not a unique paragraph. It shoud be that the VBE could create unique paragraphs to each user in the list with unik ids (pid) so that the content of each paragraph is almost unique except for the statistic field. But the statistic field will be set on unique paragraphs and thus "unique" too.
I think that it is different to Drupal 7, which made the job ok.

I'm not sure if it's VBE or paragraph that's causing the problem.
See: https://www.drupal.org/project/paragraphs/issues/3574497

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

uv516 created an issue. See original summary.

uv516’s picture

Issue summary: View changes

velmir_taky made their first commit to this issue’s fork.

velmir_taky’s picture

Status: Active » Needs review

Problem

When using Views Bulk Edit to set an entity_reference_revisions field (e.g. Paragraphs) on multiple entities, all target entities end up sharing the same paragraph entity ID. Paragraphs are composite entities — each parent must own its own copy. Sharing a single paragraph across parents causes data corruption: only the last saved parent is recorded in parent_id, and editing/deleting the paragraph on one entity affects all others.

Root cause

BulkEditFormTrait::execute() applies the same field values (including target_id) to every entity in the batch. For regular fields this is correct, but for composite entity references each entity needs a unique duplicate.

Fix

Before setting field values in execute(), the code now checks if the field type is entity_reference_revisions. If so, it calls a new duplicateCompositeFieldValues() method that loads the referenced entity and creates a fresh copy via createDuplicate() for each target entity. This ensures every parent gets its own paragraph with correct parent_id.

Changes

- src/Form/BulkEditFormTrait.php — detection + new duplicateCompositeFieldValues() method
- tests/src/Kernel/ViewsBulkEditCompositeEntityTest.php — kernel test (3 test methods, 54 assertions) covering replace, append, and non-regression for regular fields
- composer.json — added entity_reference_revisions and paragraphs to require-dev for CI