Revisions aren't deleted on cron run

Created on 15 April 2020, over 4 years ago
Updated 7 March 2024, 9 months ago

The changes in https://git.drupalcode.org/project/node_revision_delete/-/commit/20c8f6f... as part of
#3105490: Increase speed of getCandidatesRevisions() introduced a bug as the limit is applied on the subquery. The main query is the one that takes the revision timestamp into account so this leads to situations where the result set is empty even though there are candidate revisions to be deleted.

In our case the Node Revision Delete page lists we have 1255 candidate revisions to delete. We have configured revisions to be deleted automatically on every cron run, but when cron runs the getCandidatesRevisions method returns an empty result. The UI and cron use different code with different limits applied.

Applying the limit that specifies the number of revisions to return to the main query instead solves the problem.

Steps to reproduce

Prerequisites: Vanilla Drupal (8.8.5) with node_revision_delete installed and enabled.

  1. Configure node_revision_delete at /admin/config/content/node_revision_delete for the Article content type as follows:
    • Minimum to keep => 1
    • Minimum age => 1 month
    • When to delete => Always delete
  2. In the same view configure cron settings for node_revision_delete as:
    • How many revisions do you want to delete per cron run? => 1
    • How often? => Every time cron runs
  3. Create a new Article at /node/add/article and save it
  4. Edit the article 2 times so that you have 3 revisions of it in total. If you go to /admin/config/content/node_revision_delete it should show that you have 0 candidate revisions
  5. To reproduce the problem you need to have revisions old enough to be deleted. As a quick solution for this, change the timestamps to "- 10 months" by running the following SQL queries:
    • UPDATE node_field_data SET changed = changed - 26784000
    • UPDATE node_revision SET revision_timestamp = revision_timestamp - 26784000
  6. At this point if you go to /admin/config/content/node_revision_delete it should show that you have 2 candidate revisions
  7. Edit the article 2 more times so that you have 5 revisions of it in total.
  8. Go to /admin/config/content/node_revision_delete and it should show that you have 3 candidate revisions
  9. Run cron at /admin/config/system/cron
  10. Check the logs at /admin/reports/dblog and verify cron has run and verify "Starting execution of node_revision_delete_cron()" is included
  11. Go back to the node_revision_delete page at /admin/config/content/node_revision_delete, it still shows the same 3 candidates for delete

The expected outcome is that in the last step the amount of candidate nodes would be 2 as cron should 1 of them.

🐛 Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇱Netherlands seanB Netherlands

    We just added a 2.x version of the module. This is a complete rewrite based on plugins to determine which revisions can be deleted. It also uses a queue worker to actually delete revisions. Could you please test if this solves the issues you currently experience?

  • Status changed to Closed: outdated 9 months ago
  • 🇨🇦Canada adriancid Montreal, Canada

    Closing because the current development is being made in branch 2.x

Production build 0.71.5 2024