Drupal is a registered trademark of Dries Buytaert

entity_purge

No security coverage
View on drupal.org

The Entity Purge modules provides a system for purging Drupal entities. For example, daily delete all entities of type X that are older than 1 month.

Features

  • It provides a purge plugin that allows you to delete during cron entities based on their age.
  • For Commerce users, it provides a purge plugin that allows you to delete Commerce carts during cron based on their creation time.
  • Custom plugins can be written that can collect the entities to be deleted based on custom criteria.
  • Automated unit tests, so that you can sleep at night.

Usage

Currently, there is no UI. Configuration entities must be created by a developer and imported via Drush or the config UI.

As an example, to delete all nodes older than 45 days, create a file at "config/sync/entity_purge.type.my_app_old_nodes.yml" with the following content. You may change the ID of the purge type from "my_app_old_nodes" to whatever suits your case.

langcode: en
# Purges for types disabled here will not be executed. 
status: true
dependencies:
  module:
    - node
id: my_app_old_nodes
label: 'Old content items'
description: 'Purges content items older than 45 days, 200 at a time.'
plugin_id: age
plugin_config:
  # Enable debugging for testing. No entities will be deleted.
  # Use with logging enabled.
  # debug: true
  # Enable logging to monitor which entities are being deleted.
  # log: true
  # Purges will be automatically run via cron. Set to `custom`
  # if you want to call the purger yourself in your code. 
  scheduler: cron
  entity_type_id: node
  # Change to `changed` to delete nodes based on their last
  # updated time. 
  field_name: created
  # Minimum age in seconds; nodes older than this will be
  # deleted.
  min_age: 3888000
  # Do not increase this limit too much. Rather, if you have
  # too many items regularly generated - such as logs,
  # set the cron to run more frequently using a module like
  # Ultimate Cron.
  limit: 200

Import the configuration, then export it so that you get the uuid property assigned by the system.

Additional Requirements

This module only requires Drupal core versions 9+, and PHP 8+.

Supporting this Module

Create issues in the Drupal.org queue, submit MRs. If you are interested in sponsoring this module to add more features, contact the module maintainers.

Activity

Total releases
2
First release
Jun 2025
Latest release
8 months ago
Release cadence
0 days
Stability
0% stable

Releases

Version Type Release date
1.0.0-beta4 Pre-release Jun 24, 2025
1.0.0-beta3 Pre-release Jun 24, 2025