Full watchdog entry:

Notice: Undefined variable: tokens in panels_cache_object->cache() (line 212 of panels/includes/plugins.inc).

Related code:

    // And for tokens:
    $tokens = ctools_set_page_token();
    foreach ($this->tokens as $token => $argument) {
      if (isset($tokens[$token])) {
        unset($tokens);
      }
    }

    $this->tokens = $tokens;

Unset the whole variable looks somehow wrong. I guess it should be unset($tokens[$token]); instead.

Update
I'm quite sure now this the solution is correct.

Workflow as I understand it:

  1. Create panels_cache_object
    This initializes the panels_cache_object::token variable with all already existing tokens.
  2. Create / render the pane to cache.
    This adds additional tokens to the global token cache.
  3. Call topanels_cache_object::cache()
    The code fetches all available tokens into $token, now iterate over the initially fetched tokens in panels_cache_object::token and removes all tokens from $token that were already present, because they don't belong to this single pane. Last step is to assign the cleaned $token to panels_cache_object::token

Comments

das-peter’s picture

I think now I understand a little bit more what the intended goal is: "Add only the tokens to the cache object which are really related to it."

Unfortunately it seems like the "diff" doesn't work since the initial fetch of existing tokens in the constructor (panels_cache_object::panels_cache_object) contains already the cache object specific tokens.
Thus the "diff" removes not only the previous set tokens but also exactly those tokens needed by the cache object.

Only idea atm. is that somewhere a call order was changed what causes the tokens to be set before the cache object is initialized.

das-peter’s picture

Status: Needs review » Needs work

Needs definitely work ;)

fabsor’s picture

Subsribing

fabsor’s picture

I can't contribute to a better solution, as I honestly don't know enough about how the tokens work, but this patch solves the problem for me and I need it for an installation profile make file, so I'm going to do a shameless reroll of this without really contributing anything new =)

dixon_’s picture

Patch in #4 solve the problem for me too. Here's a re-roll.

It seems unreasonable to me to unset the whole $tokens variable, when what we are looking for actually is $tokens[$token]. So it seems like a reasonable fix.

Letharion’s picture

Assigned: Unassigned » merlinofchaos
Status: Needs work » Needs review

Looks like an issue that use some feedback from merlinofchaos.

das-peter’s picture

I'm quite sure now this the solution is correct.

Workflow as I understand it:

  1. Create panels_cache_object
    This initializes the panels_cache_object::token variable with all already existing tokens.
  2. Create / render the pane to cache.
    This adds additional tokens to the global token cache.
  3. Call topanels_cache_object::cache()
    The code fetches all available tokens into $token, now iterate over the initially fetched tokens in panels_cache_object::token and removes all tokens from $token that were already present, because they don't belong to this single pane. Last step is to assign the cleaned $token to panels_cache_object::token
merlinofchaos’s picture

Status: Needs review » Fixed

I agree; committed #5

bryancasler’s picture

Marked my post as a duplicate of this one #1466692: Notice thrown on page view

bryancasler’s picture

I can confirm that #5 resolves the problem I had

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Updated issue summary.

  • Commit 2002ad9 on 7.x-3.x, 7.x-3.x-i18n, 8.x-3.x by merlinofchaos:
    Issue #1173978 by das-peter and dixon_: Preent notice on caching tokens...