[PLAN] Create an index of UUIDs

Created on 19 March 2016, about 9 years ago
Updated 13 November 2024, 5 months ago

Problem/Motivation

Currently with Drupal 8 a UUID is useless. It maybe universally unique, but it doesn't really identify anything on it's own.

In Multiversion module there is multiple entity indexes for UUID, revision hash, sequence, and revision tree. All but UUID are irrelevant for core at the moment.

In Multiversion all of the indexes are grouped by workspace, which is important for how Multiversion uses these indexes. If we put indexes into core before workspaces go into core we will need to find a way for contrib modules like Multiversion to alter these indexes.

Proposed resolution

- Create an interface for all indexes
- Create a base class for all indexes
- Create an index of UUIDs with their entity type, entity id and revision id.

Remaining tasks

This is already implemented in Multiversion module, so mostly just needs porting over. However Multiversion introduces workspaces which would need to be removed from the uuid index code in a way that still allows Multiversion to add them.

Technical summary

- entity.index.uuid service
- getters and setters in service
- hook_install to add all existing entities to index
- hook_entity_insert to add new entities to index

How the indexes in Multiversion are used

The main use case is the RELAXed Web Services module which implements the CouchDB API (http://docs.couchdb.org/en/stable/http-api.html) this API focuses 100% on UUIDs, so we need a way to know when GETting or POSTing a URI which entity that relates to without looping through every entity type.

Other use cases

Make it possible to link to an entity by UUID Active - Wouldn't it be cool if we didn't need the entity type in the URI, and out UUIDs were universally identifiable?
MenuLinkContent entities pointing to nodes are not deployable: LinkItem should have a "target_uuid" computed property Needs work - Wouldn't it be cool if menu links could link to a UUID and we can look up what entity type that relates to?

Feature request
Status

Active

Version

11.0 🔥

Component

entity system

Created by

🇬🇧United Kingdom timmillwood 🏴󠁧󠁢󠁷󠁬󠁳󠁿 Wales, UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇷🇴Romania claudiu.cristea Arad 🇷🇴

    Also EntityRepository::loadEntityByUuid() can be deprecated in favour of method that only needs the UUID, without the entity type argument

  • 🇩🇪Germany c-logemann Frankfurt/M, Germany

    I completely disagree with the starting argument of 2016:
    > Currently with Drupal 8 a UUID is useless.

    There are so much things we can solve with UUIDs like config entity conflicts and hiding serial IDs (see my module U3ID . And since 2016 we have much more entity types including logs etc. and still growing. On larger systems this index would be a very huge table and should probably handled like a cache table which can be excluded in backups etc.
    Personally I only see this as an interesting idea to find an entity just via UUID. But I hope this is something we won't be dependent on this feature in future because I see a lot of performance issues coming with it. So this should be optional at all or at least optional on any (!) entity type as an OPT IN setting in my opinion.

Production build 0.71.5 2024