Problem/Motivation

A common problem when using revision logs in Drupal is that content editors don't always fill them out. As a result, the revision history for Content is often full of blank logs, which is useless to content moderators and reviewers.

Proposed resolution

Provide sane, nicely formatted logs for revisions that have none. This is a big UX improvement for content editors and finally makes the history of revisionable content entities like nodes readable.

Remaining tasks

Review the patch.

@todo File an issue for Content Moderation - it looks like $entity->original is always the default revision, but if you're using Content Moderation you're really editing the latest revision. This means that the default revision log provided by this patch will always be really long since it shows all changes between the default and latest.

@todo File an issue for the Pathauto contrib module - the path alias always appear changed when alias patterns are enabled.

User interface changes

None.

API changes

Entities that extend \Drupal\Core\Entity\RevisionableContentEntityBase or \Drupal\Core\Entity\EditorialContentEntityBase will now get default revision logs if none are provided.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

samuel.mortenson created an issue. See original summary.

Status: Needs review » Needs work

The last submitted patch, drupal-core-default-revision-log.patch, failed testing.

Wim Leers’s picture

Issue tags: +Usability

YES PLEASE

dawehner’s picture

Are you sure there is no other issue out there? I remember reviewing it and asking, why is this not a special field item,

samuel.mortenson’s picture

@dawehner #2696555: On the entity form of revisionable entities, make "create new revision" and "revision log" configurable is related, but I couldn't find anything else about creating a default revision log.

samuel.mortenson’s picture

Status: Needs work » Needs review

This should fix some of the errors, but a lot of the other failures are REST related, testing that the serialized content of entities matches some exact hard-coded value. I'll let this fail before fixing those.

samuel.mortenson’s picture

samuel.mortenson’s picture

Issue summary: View changes

Status: Needs review » Needs work

The last submitted patch, 7: core-default-revision-log-2881786-6.patch, failed testing.

samuel.mortenson’s picture

Fixed some of the test errors, hopefully!

Status: Needs review » Needs work

The last submitted patch, 10: core-default-revision-log-2881786-10.patch, failed testing.

samuel.mortenson’s picture

Missed the migrate test failures.

Status: Needs review » Needs work

The last submitted patch, 12: core-default-revision-log-2881786-12.patch, failed testing.

samuel.mortenson’s picture

Coding standards...

Status: Needs review » Needs work

The last submitted patch, 14: core-default-revision-log-2881786-14.patch, failed testing.

samuel.mortenson’s picture

So one of the two recent failures is fairly explicit about expected behavior with empty log messages:

class NodeRevisionsTest extends NodeTestBase {
...
  /**
   * Checks that revisions are correctly saved without log messages.
   */
  public function testNodeRevisionWithoutLogMessage() {
    $node_storage = $this->container->get('entity.manager')->getStorage('node');
    // Create a node with an initial log message.
    $revision_log = $this->randomMachineName(10);
    $node = $this->drupalCreateNode(['revision_log' => $revision_log]);

    // Save over the same revision and explicitly provide an empty log message
    // (for example, to mimic the case of a node form submitted with no text in
    // the "log message" field), and check that the original log message is
    // preserved.
    $new_title = $this->randomMachineName(10) . 'testNodeRevisionWithoutLogMessage1';

    $node = clone $node;
    $node->title = $new_title;
    $node->revision_log = '';
    $node->setNewRevision(FALSE);

    $node->save();
    $this->drupalGet('node/' . $node->id());
    $this->assertText($new_title, 'New node title appears on the page.');
    $node_storage->resetCache([$node->id()]);
    $node_revision = $node_storage->load($node->id());
    $this->assertEqual($node_revision->revision_log->value, $revision_log, 'After an existing node revision is re-saved without a log message, the original log message is preserved.');
...

Before jumping in and I suppose removing this test method - should the default revision log behavior be configurable per bundle? It would make this patch a lot more complex, but I don't want to cause a regression in terms of functionality.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.