Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The following token types are not defined but have tokens: $info['types']['menu-link'] #1901

Open
klonos opened this issue May 19, 2016 · 11 comments

Comments

@klonos
Copy link
Member

klonos commented May 19, 2016

I saw this in my status report and that's what made me decide to scrap my local dev and build a fresh one. The goal was to upgrade 1.3.5 to 1.3.7 and then to 1.4.2 and see if this is reproducible, but I've hit #1900. Maybe it means something to someone that knows how to fix it. If the fatal issue gets sorted, I'll see if this happens with the fresh install + upgrade to 1.4.2 and if not, I will close this issue here.

@ghost
Copy link

ghost commented Nov 1, 2020

This just happened to me. Turns out it's simply a result of disabling the Menu module (which isn't a required module, so there are use-cases for doing so).

@alanmels
Copy link

alanmels commented Aug 4, 2023

Hitting the same error, but with slightly different message:

The following token types are not defined but have tokens: $info['types']['term']

Re-enabling the taxonomy module makes it go away, however this website does not need the taxonomy.

I'm using this dirty, but quick hack for now to make the notice go away - replaced the following block in ./includes/token.inc:

  // Check tokens for problems.
  foreach ($token_info['tokens'] as $type => $tokens) {
    if (!is_array($tokens)) {
      $token_problems['not-array']['problems'][] = "\$info['tokens']['$type']";
      continue;
    }
    else {
      foreach (array_keys($tokens) as $token) {
        if (!is_array($tokens[$token])) {
          $token_problems['not-array']['problems'][] = "\$info['tokens']['$type']['$token']";
          continue;
        }
        elseif (!isset($tokens[$token]['name']) || !isset($tokens[$token]['description'])) {
          $token_problems['missing-info']['problems'][] = "\$info['tokens']['$type']['$token']";
        }
        elseif (is_array($tokens[$token]['name']) || is_array($tokens[$token]['description'])) {
          $token_problems['duplicate']['problems'][] = "\$info['tokens']['$type']['$token']";
        }
      }
    }
    if (!isset($token_info['types'][$type])) {
      $token_problems['tokens-no-type']['problems'][] = "\$info['types']['$type']";
    }
  }

with:

  // Check tokens for problems.
  foreach ($token_info['tokens'] as $type => $tokens) {
    if (!is_array($tokens)) {
      $token_problems['not-array']['problems'][] = "\$info['tokens']['$type']";
      continue;
    }
    else {
      foreach (array_keys($tokens) as $token) {
        if (!is_array($tokens[$token])) {
          $token_problems['not-array']['problems'][] = "\$info['tokens']['$type']['$token']";
          continue;
        }
        elseif (!isset($tokens[$token]['name']) || !isset($tokens[$token]['description'])) {
          $token_problems['missing-info']['problems'][] = "\$info['tokens']['$type']['$token']";
        }
        elseif (is_array($tokens[$token]['name']) || is_array($tokens[$token]['description'])) {
          $token_problems['duplicate']['problems'][] = "\$info['tokens']['$type']['$token']";
        }
      }
    }
    if (!isset($token_info['types'][$type])) {
      if ($type == 'term' && !module_exists('taxonomy')) {
        continue;
      }
      $token_problems['tokens-no-type']['problems'][] = "\$info['types']['$type']";
    }
  }

but it must be properly fixed in core.

@klonos
Copy link
Member Author

klonos commented Aug 4, 2023

Historically, this issue appears to not happen frequently, but it is annoying, so yes, it should be addressed.

It's good that we now have another way to reproduce it. Thanks @alanmels 🙏🏼

@argiepiano
Copy link

I'm not able to reproduce. This is what I'm doing:

  1. Clean install
  2. Delete the Tags field from Post
  3. Disable and uninstall Taxonomy
  4. Clear caches
    ... Nothing

Am I missing a step, @alanmels? Otherwise, I guess this must be the result of a contrib module defining tokens of type 'term' or 'vocabulary', and therefore core will complain if taxonomy is disabled, since that's were those token types are defined.

@alanmels
Copy link

alanmels commented Aug 4, 2023

On a clean website disable Taxonomy and enable Entity Tokens module and look at the Status page, and the notice should be there.

@argiepiano
Copy link

argiepiano commented Aug 4, 2023

On a clean website disable Taxonomy and enable Tolen module and look at the Status page, and the notice should be there.

Yes, that's what I'm doing. I don't see a problem in the Status page.

EDIT: I re-read. OK, yes, Entity Tokens is the issue.

@argiepiano
Copy link

OK, I was able to reproduce ONLY if:

  1. Enable Entity Plus
  2. Enable Entity Tokens
  3. Disable Taxonomy

So, the problem is not in core. The problem is that Entity Tokens defines a few custom term tokens. I'll open an issue there.

@alanmels
Copy link

alanmels commented Aug 4, 2023

Pardon me, I also have Entity Plus.

@argiepiano
Copy link

argiepiano commented Aug 4, 2023

Posted an issue in Entity Tokens:

backdrop-contrib/entity_token#43

I'll fix that tomorrow over there. The problem is in line 98 and 104 of entity_token.tokens.inc. Those need to be wrapped in an if statement.

@argiepiano
Copy link

@alanmels, this is now fixed in Entity Tokens, and just did a new release of the module. Please test.

@klonos
Copy link
Member Author

klonos commented Aug 4, 2023

In the meantime, I have been working on cross-ports for commits in the 7.x Token module (as part of the #5012 meta issue). This one specifically will affect how the status report messages look (the severity has been lowered for some of them for example): backdrop/backdrop#4489

Example of a status warning before:
image

After this change it becomes an "info" message:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants