Problem/Motivation
In #2892807: Use the minimum_age_to_delete and when_to_delete variables to delete revisions the _node_revision_delete_candidates() function was updated allowing to know if a node is candidate to delete his revisions, but the _node_revision_delete_do_delete() function was not updated, so at this time if you set the Minimum age of revisions to delete this parameter is not use it and this will not be accomplish:
Revisions older of this age will be deleted, but just only after the "Minimum number of revisions to keep" will be reached. If you don't want to take in count the age of the revisions, set to "None".
So, you can loose some revisions because this parameter is not handled at this time.
Proposed resolution
Use the minimum_age_to_delete variable in the _node_revision_delete_do_delete() function.
Remaining tasks
Update the function and all the function calls to use the minimum_age_to_delete variable.
User interface changes
None.
API changes
None.
Data model changes
None.
Comments
Comment #2
shiraz dindarThe project page says:
7.x-3.0-beta1 released 10 August 2017
Now you can delete revisions based on age and inactivity. But more test are needed before the final release.
But this functionality isn't working yet, as noted in this task! It appears to be only half built -- it's in the UI but it's not actually in the _node_revision_delete_do_delete() function as noted in this task. This threw me off and I imagine it will others. Maybe update the 3.0-beta1 release note so it doesn't mislead?
Comment #3
adriancidThanks, I see what happens, I released the version and after a user saw the problem but I forgot to update the documentation. I will update now the doc.
Comment #4
kari.kaariainen commentedHas this been fixed or not? Can I rely on Minimum age of revisions to delete? Or was this a documentation issue?
Comment #5
adriancidIs not possible at this time. Was a documentation issue
Comment #6
slydevil commentedPatch attached to accomplish this functionality. I did test as thoroughly as I could and will continue to do so, but it needs to put through it's paces.
Comment #7
slydevil commentedComment #8
adriancidThanks @slydevil I will try to port the remaining code for the node_revision_generate module to have a way to create revisions and then I will test your code.
Comment #9
adriancid@slydevil of you want to help here are the issues we need to port from the 8.x branch https://www.drupal.org/project/issues/node_revision_delete?status=15&version=8.x
Comment #10
slydevil commentedI'll take a look
Comment #11
adriancidNow is possible to create revisions (thanks to @slydevil) with this submodule #3021310: Create submodule to generate revisions.
If somebody wants to test the patch on this issue this will be great.
Comment #12
adriancidWe need these lines because the function _node_revision_delete_candidates should return the candidates nodes with revisions that can be deleted and not the number of revisions that can be deleted.
Comment #13
slydevil commented@adriancid, I did include those lines. The $when_to_delete variable is still there, but I took the strtotime call out and put it into a function called _node_revision_delete_determine_time(). The $minimum_age_to_delete is included in the second query:
Comment #14
adriancidEven if they are included the configuration page show the number of revision to delete and not the nodes with revitions that can be deleted.
You ca create 3 nodes and then create 10 revisions to each node and then go to the configuration page and you will see the diference.
Comment #15
slydevil commentedMissing a groupBy probably...I'll take a look.
Comment #16
slydevil commentedYup, adding the group by worked. New patch attached.
Comment #17
slydevil commentedComment #18
volkswagenchickTagging for DrupalNorth 2019
Comment #19
juampynr commentedOn a 20Gb database with 600.000 revisions the patch at #16 made the page admin/config/content/node_revision_delete unable to load and the Drush command unresponsive. I joined both queries into one and now the query just takes between 2 to 4 seconds. @slydevil said that joining them together may mean that the script could delete incorrect revisions but after looking at the code I did not get that impression. Can you clarify @slydevil?
Comment #20
adriancidthanks for the patch, that's what we have in the D8 version only one query, and is working fine.
Comment #22
adriancid