In the PanelizerEntityDefault.class.php, function hook_entity_update(), around rows 933 - 947, the Panelizer sets $update = array('entity_type', 'revision_id', 'view_mode'); if $this->supports_revisions is true. This causes the drupal_write_record to execute update on a database row instead of insert. Issue is that in some cases the panelizer_entity table might be missing row for that node and thus the Panelizer settings are not saved. In my opinion the code should check the $panelizer->entity_id to determine if it should do an insert or an update. Currently it uses the $this->supports_revisions to determine it.
Possible way to reproduce
- Create new content type without panelizer set
- Create nodes on that content type
- Enable Panelizer on the content type
- Try to edit nodes Panelizer settings, for example by settings a CSS class to it. Changes are not saved
- Create new node (same content) type, edit node Panelizer settings => changes are stored to panelizer_entity DB table
Possible fix to the PanelizerEntityDefault.class.php file, function hook_entity_update. This code change made it possible to edit nodes that did not previously save node Panelizer changes.
old code
if ($this->supports_revisions) {
if (empty($panelizer->revision_id) || $panelizer->revision_id != $revision_id) {
$panelizer->revision_id = $revision_id;
}
$update = array('entity_type', 'revision_id', 'view_mode');
}
else {
if (empty($panelizer->entity_id)) {
$update = array();
}
else {
$update = array('entity_type', 'entity_id', 'view_mode');
}
}
new code
if ($this->supports_revisions) {
if (empty($panelizer->revision_id) || $panelizer->revision_id != $revision_id) {
$panelizer->revision_id = $revision_id;
}
}
// If panelizer is missing entity_id, new panelizer_entity row needs to be created
if (empty($panelizer->entity_id)) {
$update = array();
}
else {
// Existing row, do an update to the row
$update = array('entity_type', 'entity_id', 'view_mode');
}
Comments
Comment #1
mikat commentedThis can be also fixed without touching the Panelizer code. Since in our project this only happens in 10-30 nodes, I created code that executes panelizer entity update.
In my case I use $_GET to get the nid so when faulty node is spotted, it can be fixed by simply setting the nid in the URL.
Comment #2
damienmckennaI'm unable to reproduce this with the current 7.x-3.x-dev release, please test it again.