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": ""
}

Comments

iainp999 created an issue. See original summary.

iainp999’s picture

I believe @vijaycs85 may already have a patch for this - we'll test and post here.

iainp999’s picture

Issue summary: View changes
pavlosdan’s picture

I 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 :)

pavlosdan’s picture

Hi @iainp999, just wondering if you had any luck with the patch or if you found another way to fix the issue.

iainp999’s picture

hey @pavlosdan - nothing yet from my side.

jlatorre’s picture

the problem also occured for Taxonomy description field and I'm not using replication, juste default_content_deploy module

timmillwood’s picture

Status: Active » Needs review
StatusFileSize
new1.74 KB

I'm wondering if we could just do this:

Status: Needs review » Needs work

The last submitted patch, 8: 2937413-8.patch, failed testing. View results

timmillwood’s picture

Status: Needs work » Needs review
StatusFileSize
new488 bytes

It 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.

timmillwood’s picture

StatusFileSize
new3.2 KB

I'm pretty sure we can safely remove the TextItemNormalizer.

vijaycs85’s picture

Status: Needs review » Reviewed & tested by the community

Hi @timmillwood,

Tested patch locally and looks working as expected (a.k.a not breaking default content). Could we get his in please?

  • timmillwood committed 8f4fb5a on 8.x-1.x
    Issue #2937413 by timmillwood, iainp999, vijaycs85: TextItemNormalizer...
timmillwood’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.