Problem/Motivation

I was surprised to see with many others that UUID of content entities (including but not limited to user and node) are not available as tokens. There is a related issue for the Token module that may cover this requirement as well, but I strongly believe that Drupal core should provide this for bundled content entities at least, just like it exposes internal ids as tokens.

Having UUIDs available as tokens could have multiple benefits. For example, numerical identifiers could be removed from path aliases in a way that permalinks would still work, unlike when human-readable but mutable entity labels are used in path aliases.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3466573

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mxr576 created an issue. See original summary.

mxr576’s picture

There is also a contrib that tries to add this missing building block, unsupported, not actively maintained: https://www.drupal.org/project/tokenuuid

mxr576’s picture

Also got the intel from @berdir on Drupal Slack that supporting UUIDs as a token probably was forgotten when the token system was migrated from Drupal 7, UUIDs were a new feature of Drupal 8+.

mxr576 changed the visibility of the branch 3466573-expose-uuid-tokens to hidden.

mxr576 changed the visibility of the branch 3466573-expose-uuid-tokens to active.

mxr576’s picture

Status: Active » Needs review

It is definitely much easier addressing this missing feature in Drupal core than in Token... Please review!

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs change record

Nice! And way to have the test coverage already done. Think we may need a simple CR to announce the new token available. Then should be good.

mxr576’s picture

Status: Needs work » Needs review
Issue tags: -Needs change record

Created a CR, I hope I guessed the version right :)

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Believe that's the right version.

quietone’s picture

Everything looks in order here. Leaving at RTBC

anybody’s picture

RTBC+1!

  • larowlan committed 19c8ac92 on 11.x
    Issue #3466573 by mxr576: Expose UUID tokens for all content entities in...

larowlan’s picture

Status: Reviewed & tested by the community » Fixed

I noticed we don't have any token integration for the following content entities
* block content
* workspace
* contact message
* shortcut

But I don't think there's any use-case for these. Personally I think there are already too many tokens (tokens, blocks and views data very fast cause OOM when reading from cache on a reasonable sized site).

But that ship has sailed and not made any worse by this issue.

Committed 19c8ac9 and pushed to 11.x. Thanks!

Status: Fixed » Closed (fixed)

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

tolstoydotcom’s picture

https://www.drupal.org/project/tokenuuid isn't unmaintained, I just pushed a D11 version. I was waiting on https://www.drupal.org/project/tokenuuid/issues/2928359 but when this patch is backported I assume tokenuuid can be marked as not needed.

mxr576’s picture

Could you please also opt-in tokenuuid to SA coverage?

This project is not covered by Drupal’s security advisory policy.