Only drafts plugin is confusing and broken

Created on 13 August 2025, about 1 month ago

Problem/Motivation

The OnlyDrafts plugin does

      // Explicitly keep draft revisions for the configured minimum age. We only
      // have an opinion on draft revisions created before the active revision.
      if ($revision_id < $active_vid && $creation_time >= $age) {
        $can_delete = FALSE;
      }
      elseif ($revision_id < $active_vid && $creation_time < $age) {
        $revision_state = $revision->get('moderation_state')->getString();
        $expected_state = 'draft';
        if (str_contains($revision_state, $expected_state)) {
          $can_delete = TRUE;
        }
      }

But it says:

    $form['age'] = [
      '#type' => 'select',
      '#title' => $this->t('The minimum amount of months a draft revision must be kept for'),
      '#description' => $this->t('After this time, draft revisions newer than the active revision can be deleted. The minimum age of revisions is always respected, regardless of other settings. Only draft revisions created after the active revision will be deleted.'),
      '#options' => $options,
      '#required' => TRUE,
      '#default_value' => $this->configuration['age'] ?? 0,
    ];

And code docblock says:

* Determines whether to delete draft revisions newer than the active revision.

Proposed resolution

I suggest that we deprecate this plugin and hide it from the UI unless it is being used. It is quite broken. My guess is that everyone who is successfully managing drafts using this module is using the drafts plugin.

Remaining tasks

Agree approach. Note that the only drafts plugin has no test coverage either.

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024