diff --git a/plugins/entity/PanelizerEntityDefault.class.php b/plugins/entity/PanelizerEntityDefault.class.php old mode 100644 new mode 100755 index c9dc149..ac5324e --- a/plugins/entity/PanelizerEntityDefault.class.php +++ b/plugins/entity/PanelizerEntityDefault.class.php @@ -657,13 +657,32 @@ abstract class PanelizerEntityDefault implements PanelizerEntityInterface { } } - if (!$ids) { + if (empty($ids)) { return; } // Load all the panelizers associated with the list of entities. if ($this->supports_revisions) { - $panelizers = db_query("SELECT * FROM {panelizer_entity} WHERE entity_type = '$this->entity_type' AND entity_id IN (:ids) AND revision_id IN (:vids)", array(':ids' => $ids, ':vids' => $vids))->fetchAllAssoc('entity_id'); + // When accessing pane configurations through the panelizer panels backend + // page, we need to make sure, that we are working on the latest display. + // Else it will work on the latest published node/display and that will in + // many cases not match the latest display, linked to a non-published + // node. + if (strpos($_GET['q'], 'panels/ajax/editor') === 0) { + $panelizers = db_query(" + SELECT + *, MAX(did) AS did + FROM {panelizer_entity} + WHERE + entity_type = '$this->entity_type' + AND entity_id IN (:ids) + GROUP BY entity_id + ", + array(':ids' => $ids))->fetchAllAssoc('entity_id'); + } + else { + $panelizers = db_query("SELECT * FROM {panelizer_entity} WHERE entity_type = '$this->entity_type' AND entity_id IN (:ids) AND revision_id IN (:vids)", array(':ids' => $ids, ':vids' => $vids))->fetchAllAssoc('entity_id'); + } } else { $panelizers = db_query("SELECT * FROM {panelizer_entity} WHERE entity_type = '$this->entity_type' AND entity_id IN (:ids)", array(':ids' => $ids))->fetchAllAssoc('entity_id'); @@ -840,6 +859,11 @@ abstract class PanelizerEntityDefault implements PanelizerEntityInterface { // And write the new record. return drupal_write_record('panelizer_entity', $panelizer, $update); } + elseif (isset($entity->panelizer) && is_array($entity->panelizer) && !empty($entity->panelizer['name']) && !empty($entity->original->panelizer)) { + $entity->panelizer = $entity->original->panelizer; + $entity->panelizer->revision_id = $revision_id; + drupal_write_record('panelizer_entity', $entity->panelizer); + } else { $entity->panelizer->entity_type = $this->entity_type; $entity->panelizer->entity_id = $entity_id;