We upgraded our development environment to 7.x-1.16 and discovered that some of the fieldable panels panes titles were displaying twice. If I re-save each pane in panelizer or pages, the duplicate Title is removed, which is time-consuming.

Comments

dsnopek’s picture

Did you run the updates (ie drush updb) and clear the cache?

dsnopek’s picture

Status: Active » Postponed (maintainer needs more info)
adamsro’s picture

Ok so it seems that the issue comes from a bad line in panopoly_magic, $form['view_mode']['#value'] = reset($form['view_mode']['#options']);, that sets the view mode equal to the view mode's label instead of value when only one view mode option exists. This wasn't an issue before but now function fieldable_panels_panes_field_extra_fields_display_alter is used to hide the title, but only if view_mode is equal to 'full', not 'Full'.

I think a good fix might be to change reset($form['view_mode']['#options']) to key($form['view_mode']['#options'])?

dsnopek’s picture

Status: Postponed (maintainer needs more info) » Needs work
Issue tags: +Regression

Oh, interesting... Thanks, @adamsro! I'm finally able to reproduce it. I wasn't able to before because my -dev site has at least one extra view mode from the Diff module, so that code wasn't getting triggered for me. And I can see that re-saving is working only because FPP now has the 'Preview' view mode. I've added new issue to clean up the view mode options:

#2430889: Hide 'preview' and 'diff_standard' view modes when adding FPPs

Your patch fixes the issue for me with new panes! But 'Full' (rather than 'full') will already be saved in the pane configuration for existing content, so we'll need a hook_update_N() put in panopoly_magic.install as well. I recommend taking a look at panopoly_widgets_update_7012() in panopoly_widgets.install as an example, which also has to update the pane configuration for all panes of a certain type.

Thanks again!

dsnopek’s picture

Priority: Normal » Critical
adamsro’s picture

@dsnopek thanks for being so on top of the issue queue. Drupal maintainer of the year award to you!

I think this patch should get everything updated correctly.

dsnopek’s picture

Thanks! :-)

Here's some quick code review (though I haven't had a chance to actually test this):

+++ b/panopoly_magic.install
@@ -0,0 +1,39 @@
+    foreach ($view_mode_options as $value => $label) {
+      if ($pane->configuration['view_mode'] === $label) {
+        $pane->configuration['view_mode'] = $value;
+
+        // Write back to the database.
+        db_update('panels_pane')
+          ->fields(array(
+            'configuration' => serialize($pane->configuration),
+          ))
+          ->condition('pid', $pane->pid)
+          ->execute();
+      }
+    }

While it probably doesn't matter (since this is an update hook that'll only ever be run once), I don't think it makes sense to loop over the $view_mode_options because there is only one $pane->configuration['view_mode'] - so why check multiple times?

We could add a break statement after it's found, but how about something like this instead:

if (($value = array_search($pane->configuration['view_mode'], $view_mode_options) !== FALSE) {
  $pane->configuration['view_mode'] = $value;

  // Write back to the database.
  // etc...
}

That should be a little more direct and clearer.

Thanks again!

adamsro’s picture

That's a good point. Here's the updated patch!

  • dsnopek committed 65cbd94 on 7.x-1.x
    Update Panopoly Magic for Issue #2426241 by adamsro: Upgrade causes...
dsnopek’s picture

Status: Needs work » Fixed

Thanks! Looks and works great. :-) Committed!

Status: Fixed » Closed (fixed)

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