Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#3 | 2341201-ctools-views-content-empty-contexts-3.patch | 725 bytes | Jorrit |
ctools-views_content-panes-only-add-context-parameters-to-contexts.patch | 712 bytes | das-peter |
Comments
Comment #2
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 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.
Comment #3
Jorrit CreditAttribution: Jorrit at nCode for DOM Digital Online Media GmbH commentedPersonally I would approach this slightly differently because the check
$argument['type'] == 'context'
is now duplicated betweenctools_views_get_argument_context()
and_views_content_panes_content_type()
.Comment #4
Jorrit CreditAttribution: Jorrit at nCode for DOM Digital Online Media GmbH commentedSteps 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]