We encountered an issue with the TextItemNormalizer when using the default_content module to export content in HAL JSON format. This was with a new node content type - no additional fields or anything like that.
The issue was discovered when trying to export content and then re-import using the default_content module when replication is also enabled.
(I did a test with the OOTB 'Article' content type and just visually checked the serializer output - on inspection, it seems to be an issue there too).
Steps:
1. Create a new node content type, and just accept the defaults.
2. Create some new content, make a note of the nid.
3. Serialize the entity. I've been using the following test code using `drush scr` in a terminal.
$entity = \Drupal\node\Entity\Node::load(3);
$serializer = \Drupal::service('serializer');
print_r($serializer->serialize($entity, 'hal_json', ['json_encode_options' => JSON_PRETTY_PRINT]));
Essentially, when replication is disabled, the body field is serialized as follows :-
...
"body": [
{
"value": "<p>It's a test!<\/p>\r\n",
"format": "basic_html",
"summary": "",
"lang": "en"
}
]
}However, when replication is enabled, we get a missing 'body' key :
...
],
"value": "<p>It's a test!<\/p>\r\n",
"format": "basic_html",
"processed": "<p>It's a test!<\/p>",
"summary": "",
"summary_processed": ""
}| Comment | File | Size | Author |
|---|---|---|---|
| #11 | 2937413-11.patch | 3.2 KB | timmillwood |
Comments
Comment #2
iainp999 commentedI believe @vijaycs85 may already have a patch for this - we'll test and post here.
Comment #3
iainp999 commentedComment #4
pavlosdanI should probably open a new issue for this but the same thing happens on fields of type "link" when replication is enabled. When replication is disabled default_content exports link fields ok.
Let me know if you would prefer a separate issue for link fields :)
Comment #5
pavlosdanHi @iainp999, just wondering if you had any luck with the patch or if you found another way to fix the issue.
Comment #6
iainp999 commentedhey @pavlosdan - nothing yet from my side.
Comment #7
jlatorre commentedthe problem also occured for Taxonomy description field and I'm not using replication, juste default_content_deploy module
Comment #8
timmillwoodI'm wondering if we could just do this:
Comment #10
timmillwoodIt might be a better solution to just use the TextItemNormalizer for json (what workspace and relaxed uses), but not for hal which is what default_content uses.
Comment #11
timmillwoodI'm pretty sure we can safely remove the TextItemNormalizer.
Comment #12
vijaycs85Hi @timmillwood,
Tested patch locally and looks working as expected (a.k.a not breaking default content). Could we get his in please?
Comment #14
timmillwood