Problem/Motivation

It can be helpful to see the title of node-revisions being deleted - so add code to node_revision_delete_cron()

Steps to reproduce

Proposed resolution

See patch - could also add as configuration option

b/web/modules/contrib/node_revision_delete/node_revision_delete.module
@@ -313,7 +313,15 @@
 
       // Delete the revisions.
       foreach ($revisions as $revision) {
+        // Get title.
+        $nid = \Drupal::database()->select('node_revision', 'nr')
+                ->fields('nr', ['nid'])
+                ->condition('vid', $revision)->execute()->fetchCol();
+        $node = $node_storage->load($nid[0]);
+
         $node_storage->deleteRevision($revision);
+
+        \Drupal::logger('node_revision_delete')->notice('id =' . $revision . ' ' . $node->title->value);
       }
       // The node_revision_delete.last_execute state variable stores the last
       // time a revision was deleted once cron run.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

Jons created an issue. See original summary.

adriancid’s picture

I think is better to add an option to enable and disable this functionality.

pick_d’s picture

Looks like this patch won't work with 2.0.0 alpha, sadly.

Could be an extremely good and necessary feature. Maybe I am doing something wrong, but as of now revisions get deleted on the cron run, and there are just no indications about that whatsoever, the log (/admin/reports/dblog) is clean, like nothing happened :-)

rp7’s picture

Title: Log revision deletion, including node title » Log revision deletion
Version: 8.x-1.0-rc6 » 2.0.x-dev
rp7’s picture

Status: Active » Needs review
StatusFileSize
new3.33 KB

Patch attached logs the following:

Deleted revision 106367 for node 3381. (responsible plugins: amount, created)

Unsure if the we really need to add the title of the revision - does it say all that much (a title can be the same for a lot of revisions).

johan den hollander’s picture

#5 patch applies to 2.0.x-dev and gives the output as stated in the comment.
@adriancid is right that this needs to be configurable on the settingspage.

joseph.olstad’s picture

#3401632: Support for Ultimate Cron

I have no idea why nrd 2.0.x does not have a hook_cron, have no idea what nrd 2.0.x does

joseph.olstad’s picture

adriancid’s picture

Status: Needs review » Needs work

We need an option to configure if we will log or not the message, maybe some people don't want to do it.

adriancid’s picture

Related issues: +#3216761: Verbose logging

  • adriancid committed 51daaefc on 2.0.x
    Issue #3321626 by rp7, adriancid, Jons, pick_d, Sharique, Johan den...

adriancid’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.