Problem/Motivation

Currently, orphaned inline block content entities can remain in the database even after their parent Layout Builder sections or references are removed. Over time, these unused entities increase database clutter and may affect maintainability and storage efficiency.

A Cron-based orphan cleanup mechanism is being added to automatically detect and remove orphaned block content entities at scheduled intervals without requiring manual intervention.

Steps to reproduce

  1. Create inline blocks using Layout Builder.
  2. Remove the block placement or delete the parent layout section/page.
  3. Observe that some block content entities remain in the database without active references.
  4. Run the existing system without cleanup logic.
  5. Notice orphaned entities continue accumulating over time.

Proposed resolution

Implement a Cron-based cleanup process that periodically scans for orphaned inline block content entities and safely deletes them.

The cleanup process will:

  • Identify block content entities that no longer have active references.
  • Run automatically during Drupal Cron execution.
  • Log cleanup operations for administrative visibility.
  • Reduce manual maintenance effort and database clutter.

Remaining tasks

  • Implement orphan detection logic.
  • Add Cron hook/service integration.
  • Test cleanup behavior on Layout Builder inline blocks.
  • Add watchdog/logging support.
  • Perform code review and documentation updates.

User interface changes

No major UI changes are introduced.

Optional status or log messages may appear in Drupal reports/logs indicating cleanup activity.

API changes

No public API changes are introduced.

Internal cleanup services or helper methods may be added to support Cron execution.

Data model changes

No database schema changes are required.

Existing orphaned block content entities may be automatically removed during Cron execution.

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

mohnish s. yadav created an issue. See original summary.

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

oshi02’s picture

Status: Active » Needs review

mohnish s. yadav’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.