| Project: | Revision Deletion |
| Version: | 6.x-1.0-rc2 |
| Component: | Miscellaneous |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
I found this node very helpful in repairing a problem on our website that was created by a bug in one of our custom modules. The bug introduced an infinite loop that added thousands of revisions to affected nodes. Fortunately, it only did this on a couple of dozen nodes. I therefore needed a way to bulk-delete revisions on just those nodes, and I also needed a way to get a listing of the nodes with lots of revisions. To do so, I created a node with PHP input format and the following code:
<?php
$sql = "SELECT COUNT(*) as count, n.nid, n.title FROM {node} n LEFT JOIN {node_revisions} nr ON n.nid = nr.nid GROUP BY n.nid ORDER BY count desc LIMIT 50";
$result = db_query($sql);
$nodes = '<ul>';
while ($row = db_fetch_array($result)) {
$nodes .= '<li>' . l($row['title'], 'admin/content/revision_deletion/node/'.$row['nid']) . ' (' . $row['count'] . ")</li>\n";
}
$nodes .= '</ul>';
print $nodes;
?>This produced a list of the 50 nodes on my site with the largest number of revisions so I could click through to each of them and manually execute the revision deletion.
I also ran into a problem with PHP timeout errors on some of my nodes, one of which had more than 4,000 revisions. It appears that the problem occurs in the revision_deletion_get_list() function when it uses the pager_query() function to limit the number of results returned. To get around the timeout errors, I modified the query by adding a "LIMIT 500" restriction at the end, as follows:
$query = "SELECT n.title, r.nid, r.vid, r.timestamp, r.uid, r.log, n.type, n.vid AS current, n.status FROM {node_revisions} r INNER JOIN {node} n ON r.nid = n.nid WHERE n.nid IN (SELECT r.nid FROM {node_revisions} r INNER JOIN {node} n ON r.nid = n.nid AND r.vid <> n.vid WHERE r.timestamp < %d $conds ) ORDER BY r.nid, r.timestamp DESC LIMIT 500";
I also entered "0" as the "Number of Revisions per Page" setting in admin settings form for revision_deletion, which prevents the function from using the pager_query() function.
I think it would be a good idea to at least add a listings page to the revision_deletion module where people can find a listing of nodes with the largest number of revisions. You could use the code I've pasted above as the basis for creating such a page.