Skip to content
Snippets Groups Projects

#2869056: Automatically set revision user/log information/created time on entity revisions

#2869056: Automatically set revision user/log information/created time on entity revisions

Closes #2869056

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
572 555 * {@inheritdoc}
573 556 */
574 557 public static function getRequestTime() {
558 @trigger_error(__METHOD__ . ' is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. No replacement provided. See https://www.drupal.org/node/3349765', E_USER_DEPRECATED);
  • Ankitha Shetty added 3 commits

    added 3 commits

    Compare with previous version

  • Hardik Patel added 225 commits

    added 225 commits

    Compare with previous version

  • 28 28 return $fields;
    29 29 }
    30 30
    31 /**
    32 * {@inheritdoc}
    33 */
    34 public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record) {
    35 parent::preSaveRevision($storage, $record);
    36 $entityType = $this->getEntityType();
    37 $revision_log_field_name = $entityType->getRevisionMetadataKey('revision_log_message');
    38 $revision_created_field_name = $entityType->getRevisionMetadataKey('revision_created');
    • Comment on lines +37 to +38

      We should use RevisionLogInterface here as well instead of using magic setters below, we can use setRevisionLogMessage and setRevisionCreationTime

    • Please register or sign in to reply
  • Adam Bramley added 1 commit

    added 1 commit

    • eec9c90a - Test coverage for setting revision user on edit to the current user.

    Compare with previous version

  • 76 79 $this->assertSame('Unnamed', $media->getName(), 'The media item was not created with the correct name.');
    77 80 $source_field_name = $media->bundle->entity->getSource()->getSourceFieldDefinition($media->bundle->entity)->getName();
    78 81 $this->assertSame('Nation of sheep, ruled by wolves, owned by pigs.', $media->get($source_field_name)->value, 'Source returns incorrect source field value.');
    82 $this->assertSame($media->getOwnerId(), $media->getRevisionUserId(), 'The media item was not created with the correct revision author.');
    83
    84 // Editing the media entity when logged in as a different user should update
    85 // the revision user.
    86 $new_user = $this->setUpCurrentUser();
    87 $media->setNewRevision(TRUE);
    88 $media->setName('a new revision')
    89 ->save();
    90 $this->assertSame($new_user->id(), $media->getRevisionUserId());
  • Adam Bramley added 1 commit

    added 1 commit

    • 466bd6b0 - Update core version in deprecation

    Compare with previous version

  • Adam Bramley added 224 commits

    added 224 commits

    Compare with previous version

  • Adam Bramley added 1 commit

    added 1 commit

    Compare with previous version

  • 476 477 $this->validated = FALSE;
    477 478 }
    478 479
    480 // If no revision author has been set explicitly, make the current user the
    481 // revision author.
    482 if ($this instanceof RevisionLogInterface && !$this->getRevisionUser()) {
    • So the test failure is because the revision user is set at this point. I don't know the rationale for putting this logic here and not alongside the other stuff in EditorialContentEntityBase but I also tried moving this there and it has the same issue - the revision user from the previous revision is still set.

      Haven't found where the revision_created field gets cleared on a new revision yet.

    • ...and changing to current user has caused a mass amount of failures. Maybe we should keep author? I'm unsure now. We can't keep it at author as that doesn't change from revision to revision.

      Edited by Adam Bramley
    • Please register or sign in to reply
  • Adam Bramley added 1 commit
  • Please register or sign in to reply
    Loading