Notice: Undefined variable: test in ctools_context_handler_get_render_handler() (line 70 of /path/to/sites/all/modules/ctools/includes/context-task-handler.inc).

Updated to the latest Dev (Oct 1st) and am now receiving this error.

CommentFileSizeAuthor
#11 ctools-1298332.patch895 bytesjramby
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

floleft’s picture

To remove the error for now, I added an isset() check for the variable inside the if($test). There may be a bigger issue though.

chriscalip’s picture

I encountered the same problem with the situation of having installed panels then disabled panels; without removing the unnecessary module : page_manager from ctools.

Disabling page_manager solves the problems.
I think this solves this issue. Please turn it back to active if this is not the case.

chriscalip’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

jbateau’s picture

Status: Closed (fixed) » Active

The code has a bug. Reinstalling page_manager just causes the bug not to be hit.
old code:

      if ($plugin['handler type'] == 'context') {
        $test = ctools_context_handler_default_test($handler, $contexts, $args);
      }
      if ($test) {
        return $id;
      }

should be:

      if ($plugin['handler type'] == 'context') {
        $test = ctools_context_handler_default_test($handler, $contexts, $args);
              if ($test) {
                return $id;
              }
      }
merlinofchaos’s picture

Interesting.

Yes there is a minor bug here. What's more interesting is that the minor bug may have revealed a bug with a task handler somewhere. When you run into this bug, do you know what the $plugin that's being checked is?

jbateau’s picture

well, I forgot about that. But the issue is that the code is simply wrong: the $test variable does not exist elsewhere in the function and therefore the code relies on it getting automatically initialized with false.
Which is Bad Practice and will cause this type of issue.

lhridley’s picture

This appeared for me when I had the Panels module activated, and subsequently deactivated it. Activating Panels again caused the notice to go away.

wxman’s picture

I was getting this using the 7.x-1.x-dev. The fix in #5 made it go away for me.

chrylarson’s picture

I had the same situation as #8 and #5 fixed it for me as well.

jramby’s picture

FileSize
895 bytes

I created a patch from #5. Wish it really fix the problem :)

merlinofchaos’s picture

Status: Active » Needs review
tim.plunkett’s picture

Status: Needs review » Fixed

This makes the else statement match the above if statement, looks good to me.

Committed http://drupalcode.org/project/ctools.git/commit/06e628c.

@jramby, you should set up your git information. You got credit on that commit (see http://drupal.org/user/603140), but it looks weird on the commit page.

Status: Fixed » Closed (fixed)

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

quinn.mckinsey’s picture

Version: 7.x-1.x-dev » 7.x-1.0

Alright, taking merilinofchaos's advice I'll post my problem here, even though I'm having this issue with 7.x-1.0 and not 7.x-1.x-dev.

Here is the situation:
I have updated drupal core from 7.12 to 7.14. I disabled all modules before upgrading, which seems to have gone well. Now I'm trying to turn the modules back on. Enabling ctools and page manager gives the error. However, the solution given on #5 does not apply as the code in context-task-handler.inc on line 70 is already corrected.

Also, turning page manager off and back on does not fix the problem. Warnings do disappear when page manager is turned off.

quinn.mckinsey’s picture

Status: Closed (fixed) » Active
quinn.mckinsey’s picture

Further update:

Enabling Panels causes the error to disappear and disabling Panels causes the error to return. Maybe, this has to do with an error on Panels part.

Hope this helps.

swentel’s picture

Status: Active » Closed (fixed)

Looks like the patch that committed introduced a new notice, patch over at #1566098: PHP notice: Undefined variable 'test' in ctools_context_handler_get_render_handler()

digibrill’s picture

Patch in #11 seemed to work for me.