Drupal Core: 8.5.0-rc1
Panelizer: 8.x-4.0
Content Translation is enabled.
Issue:
There are multiple translation of a node entity, If the source node is updated via Panelizer, the translations will be gone, because the revision of the source is updated to the latest, but not the translations. This only happens, if the node entity in question has a panelizer field that has a storage_id with its revision number. This is stored in the serialized node_revision__panelizer.panelizer_panels_display database field.
You'd assume this is a Content Translation module issue, but deep down the problem is that the Panelizer does not update the referenced revision of the page in the node_revision__panelizer.panelizer_panels_display database field. Investigating the issue, the Node bundle - via the ContentEntityStorageBase::invokeFieldMethod() parent method - calls (around line 759) the PanelizerFieldType::postSave(). The problem is, the invokeFieldMethod() assumes that the postSave() implementations are self contained: if changes need to be made, the postSave() should take care of it by itself. This is not the case for Panelizer, which alters the Node entity’s Panelizer field’s storage_id, via to the TypedData plugin Map::set() which does nothing else, so saving the entity does not happen there. This might wasn’t the case in the past and beause it is an internal part of Drupal Core, the maintainers might change it without expecting that a Contributed module, such Panelizer is relying on the internal behaviour of the Map::set().
Steps to replicate:
- Turn on Content Translation, create some available languages.
- Create a Panelizer page.
- Add translations (node/[id]/tranlsations)
- Alter the original/source entity's page with a block.
- Check the node/[id]/translations again. They gone.
bundle: cms_page
deleted: 0
entity_id: 331
<b>revision_id: 8599</b>
langcode: nl-nl
delta: 0
panelizer_view_mode: full
panelizer_default: NULL
panelizer_panels_display: a:13:{s:6:"blocks";a:2:{s:36:"7d6c6c2a-6da9-4453-aa75-aca77a75dda3";a:12:{s:2:"id";s:50:"cms_component:474504f6-930c-42a4-a3e2-eb4df6a75ae2";s:5:"label";N;s:8:"provider";s:13:"cms_component";s:13:"label_display";N;s:6:"status";b:1;s:4:"info";s:0:"";s:9:"view_mode";s:9:"component";s:25:"cms_component_interaction";a:0:{}s:15:"context_mapping";a:0:{}s:6:"region";s:9:"content_1";s:4:"uuid";s:36:"7d6c6c2a-6da9-4453-aa75-aca77a75dda3";s:6:"weight";i:1;}s:36:"f3acbf33-28b1-4cdb-a227-d2f380634bd0";a:12:{s:2:"id";s:50:"cms_component:36f545f4-8abf-42ca-8e85-b383dd573e75";s:5:"label";N;s:8:"provider";s:13:"cms_component";s:13:"label_display";N;s:6:"status";b:1;s:4:"info";s:0:"";s:9:"view_mode";s:9:"component";s:25:"cms_component_interaction";a:0:{}s:15:"context_mapping";a:0:{}s:6:"region";s:7:"heading";s:4:"uuid";s:36:"f3acbf33-28b1-4cdb-a227-d2f380634bd0";s:6:"weight";i:1;}}s:2:"id";s:14:"panels_variant";s:5:"label";s:7:"Default";s:4:"uuid";s:36:"5007aac6-b0b9-4fa2-92f6-870671a29527";s:6:"weight";i:0;s:6:"layout";s:13:":layout-promo";s:15:"layout_settings";a:0:{}s:10:"page_title";s:12:"[node:title]";s:12:"storage_type";s:15:"panelizer_field";s:10:<b>"storage_id";s:18:"node:331:full:8461"</b>;s:7:"builder";s:3:"ipe";s:7:"pattern";s:9:"panelizer";s:14:"static_context";a:0:{}}
Note: the storage_id contains a revision id (8461) that is different to the entity's actual revision id (8599), because the panelizer_panels_display is not updated during the entity save.
Please feel free to ask questions.
Comments