enabled metatag module, & goto add content page it shows below error..
The Page title is using the following invalid tokens: [node:title], [site:name].
The Description is using the following invalid tokens: [node:summary].
The Canonical URL is using the following invalid tokens: [current-page:url:absolute].
The Shortlink URL is using the following invalid tokens: [current-page:url:unaliased].

thanks in advance,

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DamienMcKenna’s picture

Priority: Critical » Normal

Had you used a previous version? Do you have the latest Token module?

Nikhil Banait’s picture

Run cron manually and clear the performance cache.

swishstar’s picture

I had a similar issue. However, I had "another error" that was happening prior to my save and once I cleared that up, then this one went away. So be sure to clear all errors that appear on "other pages" first. In my case, I had a pass-by-reference that Drupal didn't like that probably didn't allow the Token module to load properly.

DamienMcKenna’s picture

Component: User interface » Other tags
Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)

Need more details.

crutch’s picture

I experienced this error after completing upgrade d6>d7. Flushed cache and all that.

Default is still not accepting tokens. If when you manually enter something in Default, like the site name, then the page saves and tokens are able to be used for all the other fields.

I'm just beginning reconfig of site and theme. If using admin toolbar, just begin running through the list of items under the "Configuration" menu item and when reaching Page Title, is when the issue happens.

BenWrighton’s picture

#2 worked for me on D7.

EgbertB’s picture

#2 also worked for me in d.7.22

chaz1975’s picture

I tried running Cron followed by clearing cache but that didn't work.

In the end I reloaded the same version of the Token module and that seemed to do the trick.

I'm using Drush so the command is drush dl token-[version].

david_garcia’s picture

This problem happens if the token_info cache gets corrupted or is incomplete, in those cases even some token provided by core are not loaded.

I am trying to isolate a reproducible case in which this happens consistently, because a core cache get corrupted first (hook_info) preventing modules exposing tokens in module.tokens.inc files to have their tokens recognized (including core tokens exposed by the system or the node module) this ultimately leads to the failure in the original report.

#2457269: Incomplete hook_info cached if there's an error/warning during module_load_all

askibinski’s picture

So this suddenly appeared on a site to me too... Running cron and flushing all caches (also manually) does not help.

- Drupal core 7.35
- Token 1.4
- Metatags 1.4

I guess I can try to upgrade token to 1.6.

askibinski’s picture

Upgrading to token 1.6 and a drush rr did seem to fix it in this case.

brooke_heaton’s picture

#11 worked for me.

DamienMcKenna’s picture

Status: Postponed (maintainer needs more info) » Fixed

Metatag currently requires Token module v1.6, so I think this should be a-ok now.

Status: Fixed » Closed (fixed)

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

numbtongue’s picture

Not sure of the side effects but for my case I was able to fix it by disabling metatag for node->Content type on this page yourdomain.com/admin/config/search/metatags

parvind87’s picture

Running cron and subsequently clearing the cache fixes the problem
I am using drush so following commands need to run -
drush cron
drush cache-clear all

semitruckrepair’s picture

I try everything you guys recommended above but i still can't post i'm getting this error code

The hreflang value for English (English) is using the following invalid tokens: [node:url-en].

any help what i should do this is new site just start the development and i'm stuck
other provlem feed importer module it want let me see the choose file button
any suggestion help will be great thanks

DamienMcKenna’s picture

@semitruckrepair: Please create a new issue and I'll be happy to look into it with you. Thanks.

Samba B’s picture

#2 worked for me. Thanks!! I have been replacing the metatag.tokens.inc to resolve this. Thanks again for making me realize that I am doing wrong.

leisurman’s picture

For me I get
The Block title is using the following invalid tokens: [node:field-sidebar-title].

I am using token 7.x-1.6
Media7.x-1.5
File entity 7.x-1.5

When I run cron I get error
EntityMalformedException: Missing bundle property on entity of type node. in [error]
entity_extract_ids() (line 7880 of /var/www/html/upgrade2a/includes/common.inc).

There is Schema mismatch in my file_entity table

JaseerKinangattil’s picture

Guys

I just disabled Metatag: hreflang (metatag_hreflang) module and issue resolved.

Dont forget to clear the cache and run cron

prabhjotg’s picture

#2 worked for me.

Mykola Dolynskyi’s picture

Metatag 7.x-1.20 + Core 7.50 - clearing chache dont help, problem remains

DamienMcKenna’s picture

@Mykola: Make sure you have the latest release of Token, otherwise please explain which token it is complaining about.

Mykola Dolynskyi’s picture

@DamienMcKenna it complains on site:name, node:title, current-page:pager, node:summary
Tokens are 1.6, updating to 1.7 now

DamienMcKenna’s picture

@Mykola: What form are you entering those tokens - a node form, a metatag settings form?

Mykola Dolynskyi’s picture

@DamienMcKenna updated.
Cleared cache, flushed caches , runned cron ... no luck

Mykola Dolynskyi’s picture

FileSize
137.49 KB

@DamienMcKenna this
node form, populated automatically from somewhere
I never was entering values for metadata

Mykola Dolynskyi’s picture

FileSize
420.83 KB

Here is how Metatag config page looks like cfg page
Unknown, Unknown, Unknown everywhere about type

Remark says "Any items marked "Unknown" are configurations in the system for entity types or bundles which have been disabled via the API or the Settings page; they will not be used."
But they are enabled.
When try to add new default metatag in config form type list select dropdown is empty (only has "Select type") value ( /admin/config/search/metatags/config/add link )

Mykola Dolynskyi’s picture

Clearing the cahce directly from Metatag Cfg page ( admin/config/search/metatags ) - helped
But i think it is not for long. This thing started to come from Saturnday and managed this it with weired combinations which i dont remember, it was 2 times. Now it is third time
Sure i have checked reports - nothing suspective there

DamienMcKenna’s picture

@Mykola: There's something else interfering with the module, which is why it isn't working properly, you can tell this by the fact on the defaults page it says "Unknown" instead of the entity labels.

What does your settings page look like?

Mykola Dolynskyi’s picture

@Damien admin/config/search/metatags/settings page is too big for single screenshot.
As i said clearing the cache directly from admin/config/search/metatags/page - is only way to resurect proper work.
I never changed anything in metatags for 1.5 years, didnot updated anything for few months - this problem just raised without any visible reason.
If I clean cache from anywhere - the problem is back.
If from module cfg page - it is gone (works again).
I will debug/investigate how it happens later - have to move other tasks now.
My suggestion - some bad thing in Entity API happens

DamienMcKenna’s picture

@Mykola: The main thing I'm wondering about on the settings page is the "Master control for all entities" section, what does that look like?

Mykola Dolynskyi’s picture

FileSize
374.14 KB

i warned you - it is big :)
big

DamienMcKenna’s picture

Version: 7.x-1.0-beta7 » 7.x-1.x-dev
Status: Closed (fixed) » Active

@Mykola: Do you see any errors when you clear the site's caches? #2457269: Incomplete hook_info cached if there's an error/warning during module_load_all might be related.

Mykola Dolynskyi’s picture

@Damien no, no erros in drupal_set_message() no errors in watchdog (in watchdog are, but they are about my modules about forms)

I stated digging - metatag config is loaded with ctools_export_crud_load_all (in metatag_config_overview())
But where damn they are saved?
metatag_config_save() is used in form for manual adding and few addons which is not related to what i expected to find.
I expect code something like when you clear cache - there entities are iterated, tokens resolved and saved to metatag config. metatag_config_save() dont lead me to anything like this. I will try to find by something like drupal_write_record(...) - if i will find nothing i will try to update Drupal core to latest (current 7.50)

Thanks for link about Bootstrap invoking order, will check this also.

Mykola Dolynskyi’s picture

FileSize
688.17 KB

dont know if this realted to problem, but ... ?
updated core, checking results

UPD: after core updated to 7.54 - problem remains

Mykola Dolynskyi’s picture

and Rules module started to fail out with

Fatal error: Call to undefined function entity_token_tokens() in /var/www/extranet/sites/all/modules/rules/rules.module on line 1670

Rules issue solved this way

DamienMcKenna’s picture

Oh wow, that screenshot shows that the system tokens are unavailable system-wide, something is really messed up with your system!

Can you please give me a list of the hooks you're using in your custom modules, maybe one of them is doing something it shouldn't be? Also, a list of the contrib modules you're using would help, I'll download them all locally so I can review them too.

Mykola Dolynskyi’s picture

@DamienMcKenna i have > 20 000 lines in total of custom modules (client has some documentory workflow with drupal)
They are not spagetti code but to much.
What makes me confused - this all started suddenly, not after update or some "controller-close" changes, was working for months with no problems.
What i do with tokens is for example custom solver function which i call directly in custom content type save handler (hook_node_save())

function appraisal_v2_system_token_map_type($type) {
  $entity_info = entity_get_info();
  if (isset($entity_info[$type]['token type'])) {
    return $entity_info[$type]['token type'];
  }
  $cache = rules_get_cache();
  if (isset($cache['data_info'][$type]['token type'])) {
    return $cache['data_info'][$type]['token type'];
  }
  return $type;
}

function appraisal_v2_evaluate_token($text, $options, $tokenvalues, $tokentypes) {
  $options += array('sanitize' => FALSE);

  global $user;
  $olduser = clone $user;
  $user = user_load(994);
          
  $replacements = array();
  $data = array();
  // We also support replacing tokens in a list of textual values.
  $whole_text = is_array($text) ? implode('', $text) : $text;
  foreach (token_scan($whole_text) as $var_name => $tokens) {
    $var_name = str_replace('-', '_', $var_name);
    if (!empty($tokentypes[$var_name]) && !empty($tokenvalues[$var_name])) {
      $tt = appraisal_v2_system_token_map_type($tokentypes[$var_name]);
      $replacements += token_generate($tt, $tokens, array($tt => $tokenvalues[$var_name]), $options);
    }
    else {
      $replacements += token_generate($var_name, $tokens, array(), $options);
    }
    // Remove tokens if no replacement value is found. As token_replace() does
    // if 'clear' is set.
    $replacements += array_fill_keys($tokens, '');
  }

  // Optionally clean the list of replacement values.
  if (!empty($options['callback']) && function_exists($options['callback'])) {
    $function = $options['callback'];
    $function($replacements, $data, $options);
  }
  
  $user = $olduser;

  // Actually apply the replacements.
  $tokens = array_keys($replacements);
  $values = array_values($replacements);
  if (is_array($text)) {
    foreach ($text as $i => $text_item) {
      $text[$i] = str_replace($tokens, $values, $text_item);
    }
    return $text;
  }
  return str_replace($tokens, $values, $text);
}

call (from appraisal_v2_node_save())

            $subject = variable_get('appraisal_v2_'.$newstatus.'_subject', '');
            $body = variable_get('appraisal_v2_'.$newstatus.'_body', '');
            
            $tokens = array('appraisal'=>$node, 
                'reciver'=>$reciver, 
                'employee'=>$employee, 
                'manager'=>$manager,
                'status'=>$newstatus,
                'prevstatus'=>$status,
                'mailsubject'=>$subject,
                'mailbody'=>$body,
                'usermsg'=>$usermsg);
            
            $tokentypes = array('appraisal'=>'node', 
                'reciver'=>'user', 
                'employee'=>'user', 
                'manager'=>'user',
                'status'=>'text',
                'prevstatus'=>'text',
                'mailsubject'=>'text',
                'mailbody'=>'text',
                'usermsg'=>'text');

            $options = array();
            $subject = appraisal_v2_evaluate_token($subject, $options, $tokens, $tokentypes);
            $body = appraisal_v2_evaluate_token($body, $options, $tokens, $tokentypes);
        
            watchdog('Appraisal v2', "Invoking new status mail sending to " . format_username($reciver));
            rules_invoke_event('appraisal_v2_new_status', $employee, $manager, $reciver, $newstatus, $status, $node, $subject, $body, $usermsg);
            drupal_set_message("Appraisal '<i>" . $node->title ."</i>' successfully pushed to status <i>" .$status_names[$newstatus] ."</i>.<br>"
                    . "Notification is send to user <i>" . theme('username', array('account' => $reciver)) . "</i>" );
Mykola Dolynskyi’s picture

FileSize
527.27 KB

if i do kint(token_info()) on site with problems i have very few tokens
t
if on site which works file - plenty of tokens, for each field, for title, author ... everything

Mykola Dolynskyi’s picture

dpm(module_implements('token_info_alter'));

comparing to site which is ok site with problems such module implementation if hook_token_info_alter ae missing: entity_token, field_collection, file_entity ...

Mykola Dolynskyi’s picture

Reinstalling token and entity_token modules helped (used Devel tool /devel/reinstall)
Sorry for bothering, this was not related to metatag module, but may be this all posts will help somebody, who knows.
Happy end :)

smaiau’s picture

Hey Mykola,
I have the same issue for my website, reinstalling token and entity_token resolved the problem for you ?

Thanks for your reply,

deanw’s picture

After upgrading metatag, token, entity, addressfield tokens, & file entity with no success I tried #43 which fixed the issue momentarily. Finally I upgraded pathauto and the issue now seems to be gone for good.

sol358’s picture

Hello.
I have version 7 of drupal, and when updating to php 7, he gave me these errors in the token module.
Same problem:
Token types are not defined but have tokens:

$info['types']['node']
$info['types']['term']
$info['types']['vocabulary']
$info['types']['file']
$info['types']['user']
$info['types']['current-user']
Tokens or token types missing name property:

$info['types']['date']
$info['tokens']['node']['url']
$info['tokens']['file']['size']
$info['tokens']['user']['url']
$info['tokens']['date']['custom']

Help me, please.

Thanks

sol358’s picture

Hello.
I have version 7 of drupal, and when updating to php 7, he gave me these errors in the token module.
Same problem:
Token types are not defined but have tokens:

$info['types']['node']
$info['types']['term']
$info['types']['vocabulary']
$info['types']['file']
$info['types']['user']
$info['types']['current-user']
Tokens or token types missing name property:

$info['types']['date']
$info['tokens']['node']['url']
$info['tokens']['file']['size']
$info['tokens']['user']['url']
$info['tokens']['date']['custom']

Help me, please.
Thanks.

DamienMcKenna’s picture

@sol358: Please make sure all of the modules on your site are fully updated, see if that solves the problem.

sol358’s picture

Update the metatag, opengraph and token modules but it still fails.

With php 5.6 if it works but with php 7.0 I get those errors.

Thanks for your help.

sol358’s picture

if in php.ini I put:
zend_extension ="c:/wamp64/bin/php/php7.0.10/ext/php_opcache.dll"
;opcache.enable=0

The token is shown but it gives me several errors, like:

  • Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Services_JSON has a deprecated constructor in \lce_redsys\resources\json.inc on line 115
  • Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Services_JSON_Error has a deprecated constructor in lce_redsys\resources\json.inc on line 781

and many more.
If I remove commented the line zend_extension ="c:/wamp64/bin/php/php7.0.10/ext/php_opcache.dll" does not give error but token fails.

Why does this happen? Is there any solution to make it work?

Help me, please.
Thanks.

DamienMcKenna’s picture

@sol358: It looks like the services_json module has some out-of-date code that need fixing, check with that that module's issue queue for details.

In general, though, you shouldn't be disabling opcache.

In order to track down the problem with your sites, make sure that errors are being displayed and that PHP's error reporting is set to display all errors, there's likely going to be custom code or a contrib module that's breaking something.

sol358’s picture

Sorry, but I do not know what the contrib module you are talking about is.

By adding the line zend_extension = "c: /wamp64/bin/php/php7.0.10/ext/php_opcache.dll" and correcting the errors it indicated, the token already works. My question is if this would be correct ?, that is, if it would be well done like that.

Although in some pages with the php7.0 version of wampserver do not load and yet with php5.6 if they load.

Thanks.

deanw’s picture

I had thought #43 had fixed the issue but clearing cache caused the error to resurface as noted here -
https://www.drupal.org/project/token/issues/1265848#comment-11424803

After updating to php 7.1 from 7.0, clearing cache no longer causes the issue to reappear.

sol358’s picture

Hello,

With PHP7.0.10 in wampserver it works on almost every page but in some it does not load me. However with PHP5.6.25 in wampserver I load all.

Nose if the problem is php.ini or is it fails in something else. I tried to put php7.1.3 in the wampserver but I have not got it, so I have not been able to test if it works or not.

Any idea why it fails?
Thank you.

loze’s picture

I am getting this error with content tokens that are defined in a feature. Reverting the field bases in my feature makes the tokens available, but then a few hours later they are no longer there. (but the fields still are)

narquam’s picture

I've been seeing this issue on one multisite specifically but not my others. The site with the issue has a lot of other modules that use tokens enabled including a lot of commerce modules. I haven't been able to trace the cause but this issue pops up randomly and stays until I clear all cache. Clearing just token cache does not resolve the issue. Clearing cache only temporarily fixes the problem though. We're running PHP 7.1 and I've tested other versions so I'm not sure this has anything to do with PHP version. I did enough digging to find the tokens aren't defined in cache when this happens and they aren't being repopulated so Drupal isn't finding them. None of the fixes listed have worked except the temporary cache clearing fix.

Is it possible that this is caused by the size of cache being too large or is it possible the cache is somehow getting corrupted? Drupal still thinks it's valid in cache from what I can tell, at least it appears Drupal doesn't think it needs to regenerate the tokens. We're also storing our cache in memcache, which is why I'm wondering if the cache size is part of the problem.

omkarms’s picture

After running CRON, it worked for me.

yntun’s picture

Enable the error log and check if there is any warning from custom modules implemented. In our case, one of the warnings has caused the missing token issue whenever we enable/disable modules or even at running drush cc all. After we fixed this warnings, token issue doesn't come back again.

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!