Using tokens in other fields (e.g. [node:metatag:description]) is broken due to languages not being accounted for when building the token result array. When the keyed array merge (+=) happens, the structure isn't aligned with the result of metatag_config_load_with_defaults(), since the actual results are keyed by language.
The attached patch looks up the language and uses it to key into the metatags array so that the merge that immediately follows is matched with the correct structure.
Here are some steps to reproduce:
- Make sure the following modules are installed and enabled:
- Token Filter
- Metatag (and dependencies)
- Go to Configuration > Text Formats > Full HTML > Configure.
- Under "Enabled Filters" check the "Replace tokens" option and click Save configuration.
- Go to Structure > Basic Page > manage fields.
- Add a new text field. Make sure you set Text processing to "Filtered text".
- Add a new Basic Page node.
- Enter data for the required fields.
- In the Meta tags > Page title field enter "Token test".
- In your custom text field, enter "[node:metatag:title]". Make sure the text format is set to "Full HTML".
- Save your node.
- Note: the token is replaced with the node's title, not the metatag title value.