- Issue created by @s-ude
- First commit to issue fork.
- 🇮🇳India ramprassad
ramprassad → changed the visibility of the branch 3496939-taxonomy-token-entityname to hidden.
- 🇮🇳India ramprassad
The entity:name token refers to the label() only in taxonomy term and vocabulary entities. The same token returns title for node, subject for comment and the account name for user. So I think it makes sense to use the name for taxonomy and vocabulary. This change would require the test in the token module to be updated as well for which I may need to create a new issue.
- 🇨🇭Switzerland berdir Switzerland
Since there is no label token and by default name is the same as the label, I'm not entirely sure that this is really desired. It's just as likely that someone relies on this behavior.
This was recently changed in 🐛 Return translated term name on views "Content: Has taxonomy term ID (with depth)" Fixed but getName() always used label(), at least since 2014, so I'm not exactly sure when and why this would have changed.
If you customize label() you can also implement your own token that returns what you wan't.
- 🇳🇿New Zealand quietone
Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies → .
I agree that
Term::getName()
seems to have always usedTerm::label()
, which I criticised in this ticket: https://www.drupal.org/project/drupal/issues/3223302 →We had to patch the
Term::getName()
method to get around the bug that I described in the linked ticket. Without that patch it is basically not possible to have your own implementation of theTerm::label()
method because it breaks terms when you try to save them.I guess, you could say, the issue that we experienced here is because of a combination of the
name
token usingTerm::label()
andTerm::getName()
usingTerm::label()
. We just had a patch in place for the latter already, which is why we did not notice it within the scope of this ticket.Apart from all of this, I believe that my point remains: It is possible to fetch the value of all taxonomy term fields (even custom fields) with tokens, except for the
name
field. That's the only field that relies on the output of thelabel()
function. Other entity types do not seem to have this problem.Since there is no label token and by default name is the same as the label, I'm not entirely sure that this is really desired. It's just as likely that someone relies on this behavior.
If someone has changed the
Term::label()
method, they have very likely also updated theTerm::getName()
method because of the bug of which I have linked the report. If that's the case, they had the tokenname
return the actual name of the term in Drupal 9, just like we did, until the token implementation changed fromTerm::getName()
toTerm::label()
. I would conclude that it is not very likely that someone relies on theTerm::label()
output being used specifically for thename
token.I hope I did not misunderstand anything. Please let me know your thoughts and let me know if I missed a point.