Revisions in Drupal allows a user to create different versions (revisions) of the same node every time it is saved (whether it’s in Draft, In Review or Published state). Revisions helps a user track the changes made to the node over time.
This feature is available in Drupal 8 core by default and can be configured for user roles through Permissions.
Users with selected Revisions permissions can View, Revert and Delete the revisions. Users can also compare the changes between two revisions, provided the Diff module is installed.
Node Revisions in Drupal
Each revision tracks the changes made to a node every time it is saved.
This feature is enabled by default for content types in Drupal 8. However, there are ways in which Revisions could be made available for a particular content type and not for others. Similarly, Revisions could be made available per the required User Role as well.
To disable Revisions for a content type:
- Navigate to Admin > Structure > Content Type > Manage. Click on the Edit tab and then navigate to Publishing Options. Uncheck the Create new revision checkbox (as shown in the image).
- For the above content type, the Revisions tab will not be visible (as shown below).
Working with Revision of Content as a QA
The Revisions tab is available as soon as a node is created, whether it’s published or unpublished. The tab is visible once the user clicks on the Edit button of a selected content type for which revisions are enabled.
- Switching to an older version of the content type node: To perform this action, the user should click on the Revisions tab in the Edit node page (as shown in the image below). Clicking on this redirects to the Revisions page (as shown in the next image).
- On the Revisions page, a user with valid permissions should see the following:
- Clicking on the date stamp should open the page.
- Selecting two revisions and clicking on the Compare selected revisions button should compare the differences between the two revisions.
- Clicking on Compare selected revisions should redirect to the view revisions page. The content shown in Red has been removed and the one in Green has been added.
- Reverting to an older version creates a new copy of the selected version and the old version is kept intact. To revert to an older version, follow these steps:
- Check the radio button of the version to create a revision from.
- Click the Revert button.
- Click on Revert in the confirmation message to revert.
- The user gets redirected to the Revisions page and the reverted version is added as the Current revision. The old Revisions are kept intact.
- Similarly, we can also Cancel the revert action by clicking on Cancel.
- The status of the reverted node is kept the same. For example, in the image below the revision reverted from is In review and the status is the same in the reverted version. (The same will happen with a node in the Draft or Published state.)
- In the example above, the status of the reverted node is In review. Verify that the changes in the reverted node are not visible to anonymous users until it is published.
- On clicking Edit, the tab has the data from the reverted node whose status is In review (as shown in the images below).
- When a revision is performed on a node which is in Published state, the same reverted node is visible to anonymous users too.
- Revisions work independently of translations. For example, there are two language pairs. If the user reverts the changes made to a node in one language, that should not revert the node for the other language.
- An Admin can also control the creation of revisions from the Edit node, which by default is checked.
- A user should enter a Revision log message to verify how it appears on the Revisions page.
The message appears on the Revisions page below the timestamp.
- The reverted node or any revision can also be deleted if required. This can be done by clicking on the Revert button’s dropdown and clicking on Delete.
Note: To be able to delete a node, the user should have the Delete Revisions permission.
- Diff Module should be enabled to check the differences between two nodes.
- Revision Permissions should be given to the required roles to check the revisions.
- The user should not be able to uncheck Create new revisions for content types for which the Moderation workflow is enabled.
The revisions functionality in Drupal prevents us from pushing the wrong information to the website. Any unwanted changes can always be reverted to the previous correct version at any time.
Naveen Sirohi, QA Engineer - L2
He loves eating, is a great listener, and can teach anyone how to drive a car. Off work, he’s usually binge-watching episodes of his favorite shows.