Delete empty drafts during cron run
If the data, title and body field is null or empty the draft should be deleted, even if the delete draft option is turned off. These are junks and not needed. Moreover, having a button in the settings page to do the same would be great!

Thanks for the great module!

CommentFileSizeAuthor
#6 delete-empty-1460360.patch3.86 KBudvranto
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

udvranto’s picture

Removed

udvranto’s picture

2. Delete empty drafts during cron run
Adding the following line in draft.module at the end of function draft_cron will do it. It will be great if anyone can confirm.

  // Remove empty drafts
  db_query("DELETE FROM {drafts} WHERE title IS NULL AND body IS NULL AND data IS NULL");
udvranto’s picture

2. Delete empty drafts during cron run
I added an option as well.

draft.admin.inc

  $form['draft']['draft_cron_remove_timeout'] = array(
    '#type' => 'textfield',
    '#title' => t('Amount of time (Days) a draft can stay in the system without being updated'),
    '#default_value' => variable_get('draft_cron_remove_timeout', 1),
    '#description' => t('When a draft is originally created if the cron timeout is never set to 1 then it has never been updated so we need to allow these to remain for a little amount of time before they are removed'),
    '#size' => 6,
  );
  $form['draft']['draft_cron_remove_empty'] = array(
    '#type' => 'checkbox',
    '#title' => t('Remove empty drafts even if the cron removal is disabled'),
    '#default_value' => variable_get('draft_cron_remove_empty', 0),
    '#description' => t('If checked, cron will remove empty drafts even if the cron removal is disabled'),
  );

draft.module at the end of function draft_cron

    db_query("DELETE FROM {drafts} WHERE cron_remove = 0 AND updated <= %d", $updated);
  }
  // Remove empty drafts
  if (variable_get('draft_cron_remove_empty', 0) == 1)
    db_query("DELETE FROM {drafts} WHERE title IS NULL AND body IS NULL AND data IS NULL");
}
udvranto’s picture

Removed

udvranto’s picture

Status: Active » Needs review
udvranto’s picture

FileSize
3.86 KB

Please review.

udvranto’s picture

Issue summary: View changes

Separating the feature requests