Skip to content

Commit

Permalink
Clone the entity prior to adding to the queue.
Browse files Browse the repository at this point in the history
- Fixes #115.
- Resolves a depraction issue.
  • Loading branch information
jhedstrom committed May 7, 2018
1 parent ea91975 commit b6f2ab4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Subscribers.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ public function sendMessage(EntityInterface $entity, MessageInterface $message,
// Add item to the queue.
$task = [
'message' => $message,
'entity' => $entity,
// Clone the entity first to avoid any oddness with serialization.
// @see https://www.drupal.org/project/drupal/issues/2971157
'entity' => clone $entity,
'notify_options' => $notify_options,
'subscribe_options' => $subscribe_options,
'context' => $context,
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Kernel/SubscribersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public function testEntityAccess() {
$message = Message::create(['template' => $this->template->id()]);

$node = $this->nodes[0];
$node->setPublished(FALSE);
$node->setUnpublished();
$node->save();

// Add permission to view own unpublished content.
Expand Down

0 comments on commit b6f2ab4

Please sign in to comment.