Problem/Motivation

When importing data from another context, the page can get the same panel display, instead of a cloned one. By modifying one of that context page, the source context page will be updated with the same content.
Note: as the module it says, Panelizer support is experimental.

Proposed resolution

Delete display, if exists for the page, clone display from imported context.

Steps to reproduce

  1. Activate panelizer for your config page bundle and use a context, like language
  2. Go to your config page settings and hit the "Save" button (and also you can panelize it using the "Panelize Default View Mode with IPE" button)
  3. Use "Import From Another Context" to import a context where panels with IPE is set
  4. Go to front, and customize your page
  5. Go to the page from where the context was imported, check that it is also modified in the same way

Comments

zoltanb created an issue. See original summary.

zoltanb’s picture

Added patch. It should handle all cases, when source and destination context have/have no panels with IPE attached.

zoltanb’s picture

Status: Active » Needs review
zoltanb’s picture

In case you need to fix already imported pages from different contexts.


**
 * Fix wrong panel displays for config pages.
 */
function MODULE_NAME_update_7001() {
  // Locate any displays associated with the config_pages entities.
  $query = db_select('panelizer_entity', 'pe')
    ->fields('pe', ['entity_id', 'did'])
    ->condition('entity_type', 'config_pages')
    ->execute()
    ->fetchAll();

  // List for entities referencing the same display IDs.
  $dids = [];
  foreach ($query as $row) {
    $dids[$row->did][] = $row->entity_id;
  }

  $panelizer_handler = panelizer_entity_plugin_get_handler('config_pages');
  foreach ($dids as $entity_ids) {
    $count = count($entity_ids);
    if ($count == 1) {
      continue;
    }

    // Take the first display and clone it for the needed entities.
    $config_first = config_pages_load($entity_ids[0]);
    for ($i = 1; $i < $count; $i++) {
      $config = config_pages_load($entity_ids[$i]);
      // Delete wrongly assigned panel displays.
      /** @var PanelizerEntityConfigPages $panelizer_handler */
      $panelizer_handler->delete_entity_panelizer($config);
      // Copy panelizer, mark as modified, cloning will be handled by panels.
      $config->panelizer = $config_first->panelizer;
      foreach ($config->panelizer as $view_mode => $panelizer) {
        $panelizer->display_is_modified = TRUE;
        $panelizer->entity_id = NULL;
      }

      config_pages_save($config);
    }

    // Fix the first entity, it can also have wrong IDs, clone from the last.
    $config = config_pages_load($config->config_pages_id);
    $panelizer_handler->delete_entity_panelizer($config_first);
    $config_first->panelizer = $config->panelizer;
    foreach ($config_first->panelizer as $view_mode => $panelizer) {
      $panelizer->display_is_modified = TRUE;
      $panelizer->entity_id = NULL;
    }
    config_pages_save($config_first);
  }
}

  • shumer committed 4aa2331 on 7.x-1.x authored by zoltanb
    Issue #2994055 by zoltanb: Wrong panel display assigned to page with...
shumer’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

messaddo’s picture

.