Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: Rightup theme 1.0.3 — Minor update available for theme vartheme_bs5_rightup (1.0.3). Release: CommentOn 1.0.6 — Minor update available for module commenton (1.0.6). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Release: ServiceM8 Webform Integration 1.2.1 — Minor update available for module servicem8_webform (1.2.1). Release: PostfixAdmin 1.0.0 — Initial release available for module postfix_admin (1.0.0)! Release: ip_analyser 1.0.3 — Minor update available for module ip_analyser (1.0.3). Module Revived: Swagger-PHP OpenAPI 3 documentation generator 1.0.0 — Module swagger_php updated after 10 months of inactivity (1.0.0). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage.

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:

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Feb 2024
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Releases

Version Type Core Release date
1.0.x-dev Dev Feb 4, 2024
1.0.0-alpha1 Pre-release Feb 4, 2024