Commit 86746fce authored by alexpott's avatar alexpott

Issue #2940513 by Sam152, Berdir: ModerationStateFieldItemList fails after an...

Issue #2940513 by Sam152, Berdir: ModerationStateFieldItemList fails after an entity has been serialized/unserialized
parent 21dd2638
......@@ -141,7 +141,10 @@ public function onChange($delta) {
public function setValue($values, $notify = TRUE) {
parent::setValue($values, $notify);
if (isset($this->list[0])) {
// If the parent created a field item and if the parent should be notified
// about the change (e.g. this is not initialized with the current value),
// update the moderated entity.
if (isset($this->list[0]) && $notify) {
$this->valueComputed = TRUE;
$this->updateModeratedEntity($this->list[0]->value);
}
......
......@@ -173,4 +173,15 @@ public function testEntityWithNoWorkflow() {
$this->assertTrue($test_node->isPublished());
}
/**
* Test the moderation_state field after an entity has been serialized.
*/
public function testEntityUnserialize() {
$this->testNode->moderation_state->value = 'draft';
$unserialized = unserialize(serialize($this->testNode));
$this->assertEquals('Test title', $unserialized->title->value);
$this->assertEquals('draft', $unserialized->moderation_state->value);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment