Add cleanup on install or bulk action

Created on 27 January 2022, over 2 years ago
Updated 14 June 2024, 12 days ago

Problem/Motivation

When installing the module, existing entities having references that are delete, could be cleaned up.

Steps to reproduce

Install the module on a site having deleted referenced entities.

Proposed resolution

Upon install fill the queue or directly delete the references.

Remaining tasks

none

User interface changes

none

API changes

none

Data model changes

none

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium kriboogh

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¬πŸ‡§United Kingdom danharper

    I'm looking for this, if somebody can guide what the approach would be I can write a patch.

  • πŸ‡­πŸ‡ΊHungary Pasqualle πŸ‡­πŸ‡Ί Budapest

    It should NOT be at module install, and it should only be done for enabled fields (by entity_reference_purger).

    1. check the field table for missing references
    2. tell entity_reference_purger that those references are deleted
    3. show how many items were removed and/or how many added to a queue

    example:
    1. Query like this needs to be done using field and database api (for all enabled fields)

    "
    SELECT DISTINCT(field_my_media_items_target_id)
     FROM `node__field_my_media_items`
     WHERE field_my_media_items_target_id not in 
      (select mid from media);"
    

    2. call function entity_reference_purger_purge_by_entity_properties('media', $entity_id) where entity_id is a missing media id
    see πŸ“Œ refactor entity_reference_purger_entity_delete() for readability Needs review

  • πŸ‡­πŸ‡ΊHungary Pasqualle πŸ‡­πŸ‡Ί Budapest
Production build 0.69.0 2024