
Jsonapi module serialises nodes and outputs them as JSON, however the "moderation_state" property is null, even though I have saved a page in the "published" state.
After hunting for the reason why, I've discovered that ModerationStateFieldItemList is not running computeModerationFieldItemList() on an isEmpty() check, so it returns true (empty) and the serialiser sets the field value to null.
Adding this method to ModerationStateFieldItemList resolves the problem:
public function isEmpty() {
$this->computeModerationFieldItemList();
return parent::isEmpty();
}
Comment | File | Size | Author |
---|---|---|---|
#2 | 2927144-2.patch | 1.5 KB | Chris Gillis |
Comments
Comment #2
Chris Gillis CreditAttribution: Chris Gillis commentedInitial patch attached.
Comment #3
cilefen CreditAttribution: cilefen as a volunteer commentedComment #8
timmillwoodI'm closing this as a duplicate of #2915398: The moderation_state field is not computed during the creation of a new entity translation. which will implement
\Drupal\Core\TypedData\ComputedItemListTrait
in ModerationStateFieldItemList, this includes:Comment #9
Chris Gillis CreditAttribution: Chris Gillis commentedThanks Tim.