Problem/Motivation

_views_content_panes_content_type() creates a list of contexts based on the arguments configuration of the view but doesn't filter non-context argument types.
The invalid contexts added this way can lead to numerous issues.

Proposed resolution

Only add context arguments to the context list.
The simple condition if ($argument['type'] == 'context') { should do the trick.

Remaining tasks

Reviews needed.

User interface changes

None.

API changes

Nonen.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Chris Matthews’s picture

The 4 year old patch to views_panes.inc applies cleanly to the latest ctools 7.x-1.x-dev, but still needs to be reviewed and tested.

Jorrit’s picture

Personally I would approach this slightly differently because the check $argument['type'] == 'context' is now duplicated between ctools_views_get_argument_context() and _views_content_panes_content_type().

Jorrit’s picture

Steps to reproduce a problem caused by this bug are the following:

1. Create a view with a panels pane display for which one of the arguments is not set to 'source' = 'from context'
2. Add this pane to a page.
3. Edit the pane settings.
4. Under the hood, ctools_context_selector() returns an array with an empty element because _views_content_panes_content_type() returns an empty element in the contexts array.
5. Some code that doesn't handle this well is _panopoly_magic_visible_element_children() supplied by the Panopoly distribution. It assumes that all children are well-formed form elements with a #type key, which is not the case here.

Stack trace:

#3 _drupal_log_error() called at [includes/errors.inc:75]
#4 _drupal_error_handler_real() called at [includes/bootstrap.inc:2604]
#5 _drupal_error_handler() called at [profiles/openatrium/modules/panopoly/panopoly_magic/panopoly_magic.module:853]
#6 _panopoly_magic_visible_element_children() called at [profiles/openatrium/modules/panopoly/panopoly_magic/panopoly_magic.module:1120]
#7 panopoly_magic_form_views_content_views_panes_content_type_edit_form_alter() called at [includes/module.inc:1171]
#8 drupal_alter() called at [includes/form.inc:1131]
#9 drupal_prepare_form() called at [includes/form.inc:352]
#10 drupal_build_form() called at [profiles/openatrium/modules/contrib/ctools/includes/wizard.inc:125]
#11 ctools_wizard_multistep_form() called at [profiles/openatrium/modules/contrib/ctools/includes/content.inc:634]
#12 ctools_content_form() called at [profiles/openatrium/modules/contrib/panels/plugins/display_renderers/panels_renderer_editor.class.php:790]
#13 panels_renderer_editor->ajax_edit_pane() called at [profiles/openatrium/modules/contrib/panels/panels.module:1659]
#14 panels_ajax_router() called at [includes/menu.inc:527]
#15 menu_execute_active_handler() called at [index.php:21]