Log revision deletion

Created on 15 November 2022, over 1 year ago
Updated 21 March 2024, 3 months ago

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

Feature request
Status

Fixed

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom Jons

Live updates comments and jobs are added and updated live.
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.

Production build 0.69.0 2024