Skip to content

feat(folders): add DOT_NO_DELETE_NOTEMPTY_FOLDER config flag to prevent deletion of non-empty folders #35310

@dsilvam

Description

@dsilvam

Problem

Users with DELETE permission on a folder can accidentally destroy entire folder trees — including all live content, subfolders, pages, and links — in a single action. There is currently no guard against this; the operation proceeds regardless of how much content is inside the folder. This is a significant accidental-data-loss risk for teams managing production content.

Goal

Allow dotCMS administrators to enable a safety guard — via a configuration flag — that blocks deletion of any folder that still contains live content (subfolders, contentlets, links, or pages). When the flag is off, existing behavior is completely unchanged.

Reproduction Steps

  1. Have a folder with any live content inside (page, contentlet, link, or subfolder).
  2. As a user with DELETE permission on that folder, trigger folder deletion.
  3. Observed: Folder and all its contents are deleted without warning.
  4. Expected: When DOT_NO_DELETE_NOTEMPTY_FOLDER=true, deletion is blocked and a clear error message is shown.

Acceptance Criteria

  • A new dotCMS config property DOT_NO_DELETE_NOTEMPTY_FOLDER (boolean, default false) is introduced and read via Config.getBooleanProperty()
  • When true, deleting a folder that contains any live content (Folder, Contentlet, Link, HTMLPage — checked recursively) is blocked
  • A localized message key message.folder.contains.live is added to all supported cms_language_* message properties files
  • When the flag is false or absent, no behavior change from today
  • Unit/integration test covers both flag states

Proposed Implementation Notes

The guard belongs in _deleteFolder() in EditFolderAction.java. A recursive private helper isNotEmpty(Folder f) should return true if the folder or any descendant contains live content. The guard activates only when Config.getBooleanProperty("DOT_NO_DELETE_NOTEMPTY_FOLDER", false) returns true.

⚠️ System.getenv() must not be used — use Config.getBooleanProperty() per dotCMS conventions.

Target Personas

  • Content teams
  • System administrators (dotCMS)

Severity

Urgent

dotCMS Version

dotCMS 25.09.18-1 (dotEvergreen)

Links

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions