The ctools_context_get_defaults() function uses $id, $object, and $subtype variables, but neither defines them, nor receives them as function arguments.

Investigation of the $plugin array defined in plugins/contexts/entity.inc implies that $id may possibly be intended refer to an optional $plugin_definition['defaults']['id'] value.

Searching for "subtype" through ctools code reveals that it is always a separately defined variable, retrieved from code or $form_state, and neither ctools_context_get_defaults() nor its only caller, ctools_context_ajax_item_add(), provide any clue as to how the $subtype information could be retrieved.

The patch in #7 corrects the undefined variable references, and also simplifies the remaining function code.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sonar_un’s picture

Thanks for attempting to fix this issue, however I am running into this same problem as well. Unfortunately, with your patch I get other errors.

ResponseText: Notice: Undefined variable: conf in ctools_context_get_defaults() (line 619 of /includes/context-admin.inc).

pillarsdotnet’s picture

Better patch, I hope. This could *really* use some review from the ctools maintainers, as I'm not at all sure of the correctness.

pillarsdotnet’s picture

This one avoids unnecessarily renaming $plugin_definition to $plugin.

sonar_un’s picture

Unfortunately, I ran into some more issues with patch #3.

ResponseText: Notice: Undefined variable: object in ctools_context_get_defaults() (line 620 of /includes/context-admin.inc).

pillarsdotnet’s picture

Issue tags: +Needs committer feedback
FileSize
1.56 KB

Updated. Could really use review from OG developers, though.

pillarsdotnet’s picture

Issue summary: View changes

Corrected according to patch in #3

sonar_un’s picture

Wow, I know this is pretty difficult, maybe I am doing something strange here, but after your latest patch, I have yet another issue.

ResponseText: Notice: Undefined index: position in ctools_edit_context_form_defaults() (line 652 of /includes/context-admin.inc).

This is terrible for me because I can't add any contexts to panels because of this problem. I hope we can have a developer review this patch.

Thanks for all your help pillarsdotnet.

pillarsdotnet’s picture

sonar_un’s picture

@pillarsdotnet - Patch #7 was able to get through the initial error, but now there are more when actually adding the context.

ResponseText: Notice: Undefined index: #parents in form_builder() (line 1738 of /includes/form.inc).

I tried this with multiple contexts and the issue was the same.

samhassell’s picture

pillarsdotnet’s picture

Issue summary: View changes

The $object variable is also undefined.

pillarsdotnet’s picture

@samhassell: I'm not sure whether #9 is in response to #8 or to the patch in #7. Can you please explain?
EDIT: I think I see. Some of the bugs fixed by this issue were introduced by the other.
Cross-referenced in #1014866-10: Collection of small bugfixes to get ctools working properly with panels

olegsmirnov’s picture

after patch #7 error message has disappeared, but context doesn't work till now (mini-panels)..

andypost’s picture

subscribe

thsutton’s picture

subscribe

merlinofchaos’s picture

Status: Needs review » Fixed

There was a lot more going on here than just a notice. The missing $id and other missing variables caused code that was designed to help you name your contexts was completely failing. I should've dug more into that; I had noticed the code wasn't working but I had never investigated. I should have.

Anyway, I committed a proper fix. Should take care of the notices as well, but in this case, the notice actually indicated a bug.

What's odd is that for some reason, I can't make notices appear when inside the modal. They appear just fine in normal use, but they do not appear in the modal. i don't know why.

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

Anonymous’s picture

Issue summary: View changes

Updated patch reference.

xjm’s picture

Issue tags: -Needs committer feedback