Upon overriding an entity's display that previously had a default display selected, the following is repeated for all panes in the display:

Notice: Undefined index: new-253fc731-f7ac-4748-9586-0b37943c957e in panels_edit_display_form_submit() (line 162 of panels/includes/display-edit.inc).

Additionally, upon reloading, none of the panes will exist.

This appears to be related to an API change in either CTools 1.4 or Panels 3.4.

Comments

damienmckenna’s picture

Title: Customizing a pane results in errors » Overriding/customizing an entity's default display results in errors
damienmckenna’s picture

damienmckenna’s picture

Status: Active » Fixed

This does not happen with the current -dev release, seems like it was fixed recently.

damienmckenna’s picture

Status: Fixed » Active

I just triggered this, so it's not fixed yet.

祥子’s picture

Hi DamienMcKenna,recently encountered a similar problem does not know how to deal with.Environment is CTools 1.4 and Panels 3.4.

msti’s picture

I can confirm this bug with ctools 1.4 and Panels 3.4 and panels-dev

ctools 1.4 and Panels 3.3 is OK

antonyanimator’s picture

I am receiving this error

Notice: Undefined index: new-8eb5e258-7cee-4fdc-99a8-4f99d1592b13 in panels_edit_display_form_submit() (line 162 of /home/e-smith/files/ibays/eyemac3/html/sites/all/modules/panels/includes/display-edit.inc).
Notice: Undefined index: new-b6165bb7-f18c-4155-9785-903a75fde7b0 in panels_edit_display_form_submit() (line 162 of /home/e-smith/files/ibays/eyemac3/html/sites/all/modules/panels/includes/display-edit.inc).

greggmarshall’s picture

Has anyone identified is the issue with Panelizer, Panels and/or CTools?

I can reliably reproduce the error and in that case it appears the PID of each panel is completely different between the existing panel definition and the update being saved. But I'm unclear on what the intended behavior should be.

In my example, the "old_content" is

  1. new-f4520d25-4347-4be1-b0a2-910b0308707b
  2. new-4b146964-4503-436b-8945-524f246a1b8e
  3. new-0f07d3bb-5c18-465c-93a1-43f7099cb525

While the new PIDs are

  1. new-e4d7f96d-65f5-48c2-8596-af9796ec7c9a
  2. new-6e32c7f6-a3b8-4f79-87e9-f9da0ad8cc76
  3. new-1363f183-c9ee-4673-b5fb-a0436ac30893

Thus the error when line 162 executes, since it is expecting a value
if ($old_content[$pid]) {

I am assuming this is a side effect of the UUID change made in Panels/CTools from #1277908: Introduce UUIDs onto panes & displays for better exportability & features compatibility.

jonmcl’s picture

Ugh. This one was just driving me crazy. I think it is indeed related to #1277908: Introduce UUIDs onto panes & displays for better exportability & features compatibility and the addition of random UUID strings to the panel ID's of the default display.

This is an issue when configuring an entity bundle's default Panelizer display for the first time. From what I can gather, the default setting (the fields and such that need to be added to the display as panes) is generated over and over again each time panelizer_default_content_page is called. Each time it is called, new random UUIDs are generated and things never match up when you try and save the display. You can even see an error if you try and disable one of the default field panes that are added ("Invalid Pane ID" AJAX error comes back).

I think the solution is to store the newly generated default display so that it can be used, with the same random UUID panel IDs, over and over again.

Since this is my first time ever looking at the Panels / Panelizer code, I'm not going to submit a patch because there are likely issues with my solution :) But here it is for smarter minds to review.

In panelizer_default_content_page($handler, $bundle, $name, $view_mode) of panelizer/includes/admin.inc change:

  ctools_include('common', 'panelizer');
  $output = drupal_build_form('panelizer_edit_content_form', $form_state);
  if (!empty($form_state['executed'])) {
    if (!empty($form_state['clicked_button']['#save-display'])) {
      drupal_set_message(t('The settings have been updated.'));
      $panelizer->display = $form_state['display'];
      ctools_export_crud_save('panelizer_defaults', $panelizer);
    }
    else {
      drupal_set_message(t('Changes have been discarded.'));
    }

    panels_edit_cache_clear($form_state['display cache']);
    drupal_goto($_GET['q']);
  }

to

  ctools_include('common', 'panelizer');
  $output = drupal_build_form('panelizer_edit_content_form', $form_state);
  if (!empty($form_state['executed'])) {
    if (!empty($form_state['clicked_button']['#save-display'])) {
      drupal_set_message(t('The settings have been updated.'));
      $panelizer->display = $form_state['display'];
      ctools_export_crud_save('panelizer_defaults', $panelizer);
    }
    else {
      drupal_set_message(t('Changes have been discarded.'));
    }

    panels_edit_cache_clear($form_state['display cache']);
    drupal_goto($_GET['q']);
  } else {
    panels_edit_cache_set($form_state['display cache']);
  }

The only problem I can see with solving the issue this way is that if the site builder does not submit or cancel the form, the default display will be cached and re-used the next time and it might not contain newly added fields that it should. So it might be a good idea to clear this object when "Provide initial display" option is first turned on for a particular view mode.

jonmcl’s picture

Whoops.. didn't quite work because the page reloads after a save or cancel and the ctools_object_cache objects keeps getting re-saved.

So it should be:

 ctools_include('common', 'panelizer');
  $output = drupal_build_form('panelizer_edit_content_form', $form_state);
  if (!empty($form_state['executed'])) {
    if (!empty($form_state['clicked_button']['#save-display'])) {
      drupal_set_message(t('The settings have been updated.'));
      $panelizer->display = $form_state['display'];
      ctools_export_crud_save('panelizer_defaults', $panelizer);
    }
    else {
      drupal_set_message(t('Changes have been discarded.'));
    }

    panels_edit_cache_clear($form_state['display cache']);
    drupal_goto($_GET['q']);
  } elseif ($form_state['display cache']->display->did === 'new') {
    panels_edit_cache_set($form_state['display cache']);
  }
damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new1.22 KB

The code from #10 in patch format.

uzlov’s picture

StatusFileSize
new652 bytes

panelizer-n2229033-11.patch - seems like this patch is not correct
need to change panelizer/includes/admin.inc
added correct patch

Status: Needs review » Needs work

The last submitted patch, 12: panelizer-save_new_panes-2229033-12.patch, failed testing.

uzlov’s picture

StatusFileSize
new572 bytes

fixed patch

uzlov’s picture

StatusFileSize
new572 bytes

patch with correct name

damienmckenna’s picture

Status: Needs work » Needs review
damienmckenna’s picture

StatusFileSize
new494 bytes

Patch #15 with the correct file path.

The last submitted patch, 15: panelizer-save_new_panes-2229033-15.patch, failed testing.

damienmckenna’s picture

Status: Needs review » Fixed

This solved the problem in my local testing. Thanks uzlov! Committed.

  • DamienMcKenna committed 435e7e8 on 7.x-3.x
    Issue #2229033 by uzlov: Fixed problem due to CTools API change which...

  • DamienMcKenna committed 4315661 on 7.x-3.x authored by uzlov
    Issue #2229033 by uzlov: Fixed problem due to CTools API change which...
  • DamienMcKenna committed f8b03ac on 7.x-3.x
    Revert "Issue #2229033 by uzlov: Fixed problem due to CTools API change...
damienmckenna’s picture

(reverted and committed a second time so that proper attribution could be given to uzlov)

Status: Fixed » Closed (fixed)

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