Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295308

Entities tokens might cause problems when field prefix is empty

$
0
0

Problem/Motivation

If we remove the "body" field from a node content type and add another text field called "summary" to that content type, the token [node:summary] is not working anymore when field prefix has been removed.

Steps to reproduce

  • Install and activate Token module
  • Alter field_ui.settings.yml, set field_prefix: '' and import the config
  • Manage the Page content type fields, remove the body field
  • Add a text field called "Summary" (with "summary" as machine name) to the Page content type fields
  • Create a page node and fill in your summary field
  • Use the token (ex: in a metatag content type description add [node:summary])
  • Check the use of your token, no data comes up (with the previous example: View your node and access the source code ; there is no meta description)

Proposed resolution

One of the solutions would be to rename the token, since [node:summary] token is related to the body field it should therefore be called [node:body_summary] or [node:body:summary].

As it might break things on a lot of websites using that token, and since this would only solve the problem for the [node:summary] token when it can also happens with any other node tokens, the other solution would be to forbid to give a machine name equal to a node token key (nid, vid, type, title, body, summary, langcode, url, created, changed, author) when we create fields with an empty field_prefix.

I am attributing this issue to the node system component because I met the problem with the nodes but we can have the same problem with any other entity (taxonomy term, user, etc.) so it's something which should be done for all entities tokens.
And it's not related to the Token module, node.tokens.inc, taxonomy.tokens.inc, user.tokens.inc are stored in the core files so it should be fixed directly in core (+ Token module could be enabled after the fields have been created so it doesn't make sense to fix this in the Token module).


Viewing all articles
Browse latest Browse all 295308

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>