From 4203cff7ac02f3f5b916286fc885a383f1718e3a Mon Sep 17 00:00:00 2001 From: Dave Long Date: Wed, 22 Nov 2023 22:28:23 +0000 Subject: [PATCH] Issue #3403265 by acbramley: Remove RevisionLogEntityTrait overrides in BlockContent --- .../block_content/src/Entity/BlockContent.php | 58 ------------------- .../src/Kernel/BlockContentRevisionsTest.php | 53 +++++++++++++++++ 2 files changed, 53 insertions(+), 58 deletions(-) create mode 100644 core/modules/block_content/tests/src/Kernel/BlockContentRevisionsTest.php diff --git a/core/modules/block_content/src/Entity/BlockContent.php b/core/modules/block_content/src/Entity/BlockContent.php index 7e652eea8ad..b94a847ad72 100644 --- a/core/modules/block_content/src/Entity/BlockContent.php +++ b/core/modules/block_content/src/Entity/BlockContent.php @@ -8,7 +8,6 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\block_content\BlockContentInterface; -use Drupal\user\UserInterface; /** * Defines the content block entity class. @@ -242,63 +241,6 @@ class BlockContent extends EditorialContentEntityBase implements BlockContentInt return $this; } - /** - * {@inheritdoc} - */ - public function getRevisionCreationTime() { - return $this->get('revision_created')->value; - } - - /** - * {@inheritdoc} - */ - public function setRevisionCreationTime($timestamp) { - $this->set('revision_created', $timestamp); - return $this; - } - - /** - * {@inheritdoc} - */ - public function getRevisionUser() { - return $this->get('revision_user')->entity; - } - - public function setRevisionUser(UserInterface $account) { - $this->set('revision_user', $account); - return $this; - } - - /** - * {@inheritdoc} - */ - public function getRevisionUserId() { - return $this->get('revision_user')->entity->id(); - } - - /** - * {@inheritdoc} - */ - public function setRevisionUserId($user_id) { - $this->set('revision_user', $user_id); - return $this; - } - - /** - * {@inheritdoc} - */ - public function getRevisionLogMessage() { - return $this->get('revision_log')->value; - } - - /** - * {@inheritdoc} - */ - public function setRevisionLogMessage($revision_log_message) { - $this->set('revision_log', $revision_log_message); - return $this; - } - /** * {@inheritdoc} */ diff --git a/core/modules/block_content/tests/src/Kernel/BlockContentRevisionsTest.php b/core/modules/block_content/tests/src/Kernel/BlockContentRevisionsTest.php new file mode 100644 index 00000000000..6c5c234e696 --- /dev/null +++ b/core/modules/block_content/tests/src/Kernel/BlockContentRevisionsTest.php @@ -0,0 +1,53 @@ +installEntitySchema('user'); + $this->installEntitySchema('block_content'); + } + + /** + * Tests block content revision user id doesn't throw error with null field. + */ + public function testNullRevisionUser(): void { + BlockContentType::create([ + 'id' => 'basic', + 'label' => 'A basic block type', + ])->save(); + + $block = BlockContent::create([ + 'info' => 'Test', + 'type' => 'basic', + 'revision_user' => NULL, + ]); + $block->save(); + $this->assertNull($block->getRevisionUserId()); + } + +}