Problem/Motivation
It is not reliable to deploy configuration of Views that reference taxonomy terms when the local site and production site are not exactly matching because they reference the Term ID (content) rather than the UUID. Creating a view which has a filter on a term from a node field should export to configuration with UUID filter values rather than taxonomy term entity IDs.
Steps to reproduce
- Create a term in a local site
- Content editor creates multiple a term in production in a different order than local
- Term IDs don't match but UUIDs would
- Since Term IDs don't match, the View is unexpectedly configure to filter by the wrong term.
Proposed resolution
Views configuration with filters on taxonomy terms should use the UUID of the entity chosen. On the front-end, keep everything using entity IDs. On the back-end (storage), store IDs as UUIDs, and convert them when passing between the front-end.
Remaining tasks
Needs work:
- #115: $view->calculateDependencies() is not returning the 'content' references
Tasks completed:
Support viewing, editing and saving the filter form with text/autocomplete.Support viewing, editing and saving the filter form with select options.Ensure that views are displaying the correct results.Update existing schema: Ensure that views can be saved and re-read properly, with the same config.Migrate existing data: Add update hook to convert entity IDs in config to UUIDs.Fix test failures.
User interface changes
None
Introduced terminology
N/A
API changes
N/A
Data model changes
Views configuration will store references to taxonomy terms as UUIDs not IDs.
Release notes snippet
Change record added here: https://www.drupal.org/node/3464158
Original proposal
Add a checkbox to the filter configuration form to allow users to use the uuid of the term as the filter value rather than the tid.
As a stop-gap until this is implemented in core, I implemented it as a custom filter which extends the current taxonomy term id filter. This may help in determining which parts of the code need to be touched when implementing https://gist.github.com/acbramley/1127c4698a9ae86885e03716f47e3281