All of my tokens have disappeared. In every replacement pattern dialog I have "no tokens available".

If I edit any of the settings in the following modules - all of which are dependent on token -:

metatag
page title
file field paths

...I get "token [site:name] invalid" errors, for each and every one of them.

I've been turning modules on and off for hours to try and establish the source of the problem, but cannot. I know that some of the tokens are now in core, so not sure if they might've gone during the last core update and I just haven't noticed.

Anyone got any idea how to restore them? Or experienced the same problem with recent updates?

Comments

Rhicreate’s picture

I've just noticed that this is what is in my status report:

Warning Tokens Problems detected

The following token types are not defined but have tokens:

$info['types']['file']

If that's any help...

Dave Reid’s picture

It sounds like there is a conflict in token info, or there is a caching problem. Try clearing out the cache_token table (or the equivalent bin if you're using an alternative cache method).

Rhicreate’s picture

Thanks, I've tried flushing cache_token but it doesn't seem to have helped.

Your post did remind me that I fairly recently installed Boost on this particular site though, I wonder if that is caching data somewhere too - I haven't had this occur on other sites with the same combo - but it caches data elsewhere, so perhaps I have just not identified the right bit of cached data yet!

The search continues...

Rhicreate’s picture

Right, well I rooted out all of Boost, suspecting that might be causing an issue, stripped back all the modules that rely on token so that I could uninstall and reinstall the module, cleared the cache over and over, browser and data cache, manually cleared out everything Boost left behind, and I still have no tokens... damn. It was working fine until recently: that's what I don't get.

Rhicreate’s picture

Ah, progress (?), I've got an error now:

    Notice: Undefined index: types in token_get_token_problems() (line 292 of modules/token/token.install).
    Warning: Invalid argument supplied for foreach() in token_get_token_problems() (line 292 of modules/token/token.install).
Notice: Undefined index: tokens in token_get_token_problems() (line 307 of modules/token/token.install).
Warning: Invalid argument supplied for foreach() in token_get_token_problems() (line 307 of modules/token/token.install).

This only came up after I've turned off Rules and Entity Token, the cache_token table in my DB is completely empty. I've installed and then removed and reinstalled token a couple of times, and it continues giving me this error.

Does that shed any light as to the source of the error perhaps?

danarich’s picture

Similar (probably the same) problem after new install of Dupal 7.22 and Token 7.x-1.5. Problem appeared after running Cron

Here are the error messages:

Notice: Undefined index: types in token_get_token_problems() (line 292 of C:\HostingSpaces\danarich\richardancestry.com\wwwroot\ra\sites\all\modules\token\token.install).
Warning: Invalid argument supplied for foreach() in token_get_token_problems() (line 292 of C:\HostingSpaces\danarich\richardancestry.com\wwwroot\ra\sites\all\modules\token\token.install).
Notice: Undefined index: tokens in token_get_token_problems() (line 307 of C:\HostingSpaces\danarich\richardancestry.com\wwwroot\ra\sites\all\modules\token\token.install).
Warning: Invalid argument supplied for foreach() in token_get_token_problems() (line 307 of C:\HostingSpaces\danarich\richardancestry.com\wwwroot\ra\sites\all\modules\token\token.install).

patrickroma’s picture

Got the same errors as #6...

Rhicreate’s picture

Was yours a new install too? And when did the errors start?

I still haven't fixed this on my website, instead I've turned off tokens and written custom code to cover my metatag and page title needs for now... but I'd still like to find out what started it!

patrickroma’s picture

Actually it was a conflict with the leaflet module => https://drupal.org/node/2060223
Probably you need to switch off all modules and check when the errors are gone, then you could try to set the module weight in the DB to 99, so that it gets fired after token module, this helped as explained in https://drupal.org/node/2060223

Rhicreate’s picture

I see. Yeah, I've yet to find an appropriate time to take them all down (production site) and work out where any conflict is... I haven't got leaflet installed, so that rules out that one for me! :D

adiatis’s picture

Some information:

New Drupal 7.23 installation
a few modules and
Entitiy Token
Rules
and Google Contacts Synchronizer

If I disable the module 'Google Contacts Synchronizer', tokens are available again.

Hope this helps someone...

dewolfe001’s picture

I don't have Google Contacts Sychronizer. I do have the same problem as seen here by others. Token Help shows all of the tokens. The tokens are not being swapped out:

Token 7.1.5
Drupal 7.23

Would going back to 7.1.1 be way to fix this?

Thanks in advance,

- Shawn

dewolfe001’s picture

Issue tags: +token

I have done a little more digging. This looks like a problem in the token.inc in core.
I added a drupal_set_message() to bleat when token_info() is called. On my status report page, the token_info() appears to be called. On the node and node edit pages the token_info() is not being called. No call, no load, no token swap out.

My question: what calls token_info() to execute?

dewolfe001’s picture

My problem was specific to a failure of the webforms to load and parse tokens. My resolution for my problem was to remove the webform module and instead use "webform_patched" https://drupal.org/project/webform_patched

I hope that info helps someone else out there.

- Shawn

behoppe333’s picture

I created a custom module that works on my test site, but when I enable it on my production site I get the "no tokens available error" described here. This is my first-ever custom module. I am not a programmer and so I am not quite able to follow the details in this discussion thread. Any newbie-oriented help appreciated.

More details about my setup:

  • Drupal Commons 3.3 (running on Drupal 7.23)
  • My custom module consists of this code (for auto-following a group) with the requisite .module and .info wrapping described by the module tutorial.
liquidcms’s picture

Issue summary: View changes

stumbled upon this issue many years later... doing a registry rebuild fix it for me.

pamelalies’s picture

I was trying to track down this issue with disappearing tokens (and metatags) for a couple of months, and I finally found the solution for our sites! I thought I would post it here in case anyone else might have the same root cause - because it wasn't an easy one to track down.

This issue broke all site tokens, so it was messing up lots of things - anywhere tokens were used on the sites. It was causing blank webform submission emails to be sent (because the data is fed into the emails via tokens), and several other nasty things.

I know a lot of people mentioned that it started happening after upgrading PHP to 7. In our case the problem was caused by the Colorfield module, which has some of the "curly braces" code, which is deprecated in PHP 7.4.

I applied this patch to our installed Colorfield module, and it fixed this issue that's been plaguing us.

https://www.drupal.org/project/colorfield/issues/3163653

You wouldn't think that a module throwing a warning would break so many other things, but in this case it did. If this isn't your exact problem, you might try fixing any other curly braces deprecations in any other modules you might have installed and see if it helps you as it did us.

I'm posting this solution everywhere I see people talking about this issue (which is a lot of posts on Drupal.org!) to help as many fellow developers as possible...hope it helps!