Problem/Motivation

Upgrading CTools threw the following error:
Warning: Undefined variable $rcontexts in ctools_context_get_context_from_relationships() (line 1442 of ctools/includes/context.inc).

Steps to reproduce

I cannot reproduce this in a vanilla install, so it seems to rely on a number of factors in our configuration.

Proposed resolution

Define the variable outside the if condition so it is defined for the call to ctools_context_get_context_from_relationship()

Remaining tasks

Merge Request pending.

User interface changes

None

API changes

None

Data model changes

None

Issue fork ctools-3346615

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

darkodev created an issue. See original summary.

joelpittet’s picture

Status: Active » Needs review

joelpittet’s picture

Status: Needs review » Fixed

Thanks @darkodev, there are possible paths where the variable is not initialized, seems safe enough to commit

joelpittet’s picture

@darkodev please take a look at #3216839: Incorrect context passed to ctools_context_get_context_from_relationship() as it has a similar change and another change, needs a review considering I committed this

darkodev’s picture

@joelpittet My fix addresses the primary issue in https://www.drupal.org/project/ctools/issues/3216839:
"[...] if the relationship's context is not present, then the context passed to the relationship is whatever the variable $rcontexts was last set to in the previous loops."
"The quick fix for passing the wrong context would be to ensure $rcontext is unset/reset on each loop."

Setting $rcontexts to array() or NULL does not seem to change the behaviour of ctools_context_get_context_from_relationship(), but setting it to NULL would align it with the other issue.

Perhaps the secondary issue in https://www.drupal.org/project/ctools/issues/3216839 about contexts qualifies as a separate issue, as it is specific to views_panes.inc?

Status: Fixed » Closed (fixed)

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