This project is not covered by Drupal’s security advisory policy.
Replace references to one entity with another. Primary expected use case: to 'merge', or remove duplicate entities, updating every other entity that references the one to be removed the one being 'merged' into.
Features
The module's first audience is developers to use with drush having made a database backup.
It is active development but might also become suitable for developers to use as an API for creating a UI for 'merging' Taxonomy Terms or any other entities and updating all references to them.
- Find all fields that could reference an entity
- Update references on these fields with a batch operation
- Handle references in translations
Usage
Install as standard module. A drush command referenced_entity_replace should become available.
drush --help referenced_entity_replace
Update all references to an entity to another and remove.
Examples:
referenced_entity_replace taxonomy_term 5 6 Updates references to term 6 to 5 and removes
--batch-size=5 term 6.
Arguments:
entity_type_id Type of entity type.
new_entity_id The entity to reference.
old_entity_id The entity that is referenced to be removed.
Options:
--batch-size[=BATCH-SIZE] Number of entities to update per batch. [default: 10]
--no-delete-old Set if you don't want to remove the old entity.
The two classes included are: BatchReplace used by the Drupal command, but could be used for a Form batch, to create the batch, and run the operations updating all field values, and optionally removing the old entity; and ReplaceHelper available as the service referenced_entity_replace.helper which will return reference fields, and actually update entities.
Similar projects
For taxonomy term references, without batch operations:
For more entities, without batch operations, but with a UI:
Project information
Seeking co-maintainer(s)
Maintainers are looking for help reviewing issues.- Project categories: Administration tools, Content editing experience, Developer tools
1 site reports using this module
- Created by ekes on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
Releases
Development version: 1.0.x-dev updated 2 Mar 2024 at 12:24 UTC
