Revision Log Default
Automatically generates sensible default revision log messages for content entities when none are provided by the user.
revision_log_default
Install
composer require 'drupal/revision_log_default:8.x-1.4'
Overview
Revision Log Default is a utility module that automatically populates revision log messages for any Drupal content entity that supports revision logging. When a user saves content without providing a revision log message, this module generates a meaningful, human-readable message describing what was changed.
The module works transparently in the background with no configuration required. It integrates seamlessly with core's content moderation workflow and third-party modules like Workbench Moderation, ensuring that revision logs accurately reflect the latest changes even when working with draft revisions.
This module solves the common problem of empty revision histories by ensuring every content change is documented, making it easier to track the history of content modifications over time.
Features
- Automatically generates revision log messages when none are provided by the user
- Creates contextual messages based on the type of change: new content creation, translation creation, or field updates
- Lists specific field names that were modified when updating existing content (e.g., 'Updated the Title and Body fields')
- Handles grammatically correct messages for different numbers of changed fields (singular, dual, and plural forms)
- Properly sets revision creation timestamp when it matches the original (common with REST API, Quick Edit, or custom code)
- Automatically sets revision user ID, falling back to entity owner when current user is anonymous (useful for CLI and migrations)
- Integrates with Content Moderation module to compare against the latest revision rather than the default revision
- Integrates with Workbench Moderation module for legacy moderation workflows
- Intelligently handles special field types including path fields and comment fields
- Ignores revision-related fields and the 'changed' timestamp when determining which fields were modified
- Works with any content entity type that implements RevisionLogInterface (nodes, media, custom entities, etc.)
Use Cases
Editorial Workflow Audit Trail
Content editors working on a news site frequently update articles but rarely remember to enter revision log messages. With Revision Log Default enabled, every save is automatically documented. When an editor updates the headline and featured image, the revision log shows 'Updated the Title and Image fields', creating a complete audit trail without requiring manual input.
Multilingual Content Management
A translation team adds French and German translations to existing English content. When they create new translations, the module automatically logs 'Created French translation' and 'Created German translation', making it easy to track which translations were added and when.
REST API and Headless Drupal
A decoupled application updates content via Drupal's REST API. Since API clients rarely provide revision log messages, Revision Log Default ensures all API-driven changes are documented. The module also correctly sets the revision timestamp even when the API doesn't provide one.
Content Migration
During a migration from a legacy CMS, content is imported via Drush or migration scripts. The module sets appropriate revision user IDs (falling back to the content owner when running as anonymous) and generates 'Created new Article' messages for all migrated content.
Quick Edit Changes
Users making inline edits with Quick Edit module often don't have access to the revision log field. Revision Log Default automatically documents these quick changes, such as 'Updated the Body field', ensuring inline edits are properly tracked in the revision history.
Tips
- The module works automatically once enabled - no configuration is needed
- User-provided revision log messages always take precedence; the module only fills in empty logs
- The module is particularly useful for sites with editorial workflows, as it ensures every content change is documented
- Works with any custom content entity type as long as it implements RevisionLogInterface
- Consider enabling this module early in a project to build up a complete revision history from the start
Technical Details
Hooks 1
hook_entity_presave
The module implements hook_entity_presave() to intercept content entity saves and populate the revision log message when empty. This hook fires for all content entities that implement RevisionLogInterface.
Troubleshooting 3
Ensure the content entity type implements RevisionLogInterface. Custom entity types must have revision support enabled with the proper revision_metadata_keys defined in their entity annotation.
Some complex field types may not work perfectly with the field comparison logic. The module uses the equals() method on field item lists. If a custom field type doesn't implement this correctly, changes may not be detected.
Some fields may have their values altered by other hooks or processes before the presave hook runs. This can cause the module to detect changes that weren't made directly by the user.