Problem/Motivation
Identified problem detailed in #962664-9: Taxonomy Index for unpublished entities:
It is possible to query by field value in views. One of the drawbacks is, by default, you can only query by TID, not Term Name. Having the values in the taxonomy_index table gets around this issue.
And #962664-47: Taxonomy Index for unpublished entities:
In Drupal prior to 7.x there was an easy way to get all the terms associated with a particular node. In 7.x and beyond, it is very difficult, if not impossible, to get that list of terms. I maintain the tac_lite module, which controls access to nodes based on the terms they are tagged with. Currently there are edge cases where tac_lite cannot learn all the terms a node is tagged with.
And described in #962664-50: Taxonomy Index for unpublished entities:
So a relationship bewteen the contents and taxonomy terms is only recognized within a view, when the contents are published, which looks like a bug to me though. I didn't want my contents to be available as separate pages, but only as the source for the view(s). Since there is the filter criteria "Content: Published (Yes/No)" for views, they seem to be designed to support the output of the not published contents as well, so I think the relations to taxonomy terms should work for such not published contents as well.
Please note that a contrib module was also introduced to fix this in #962664-16: Taxonomy Index for unpublished entities:
I have written http://drupal.org/project/taxonomy_entity_index in the meantime to index all entities regardless of published or not. I've opened an issue to add views integration for it.
Per #962664-27: Taxonomy Index for unpublished entities:
Well, I think leaving out unpublished nodes was a design feature to reduce overhead, since this table can get crazy-big on a large site. Technically you could use the EFQ to look up unpublished nodes by taxonomy--fetch a list of all fields, look for taxonomy fields, look up which bundles have these fields, and loop to query against values in all these fields. But that's kinda wild.
Drupal 7 version of this issue: #2878046: D7 Taxonomy Index for unpublished entities
Steps to reproduce
I believe this edge-case is defined in #962664-50: Taxonomy Index for unpublished entities best:
So a relationship bewteen the contents and taxonomy terms is only recognized within a view, when the contents are published, which looks like a bug to me though. I didn't want my contents to be available as separate pages, but only as the source for the view(s). Since there is the filter criteria "Content: Published (Yes/No)" for views, they seem to be designed to support the output of the not published contents as well, so I think the relations to taxonomy terms should work for such not published contents as well.
Proposed resolution
Proposed change should update the taxonomy index for unpublished entities. Example use case is where editors manipulate the taxonomy terms of unpublished nodes to be used by a view that searches unpublished nodes by taxonomy term name (as opposed to tid, which can be search by taxonomy_field_name_instance).
Remaining tasks
See #962664-179: Taxonomy Index for unpublished entities:
We need to check the views query on taxonomy/term/{term} pages before and after the patch (with a lot of records in the index table), and compare the before/after EXPLAIN.
And per @xjm on Slack:
- the taxonomy API, and Drupal overall, is very, very different than it was when this issue was proposed, so we really need people to think seriously about whether it makes sense anymore
User interface changes
@tbd
API changes
@tbd
Data model changes
Change record as seen in #962664-159: Taxonomy Index for unpublished entities: https://www.drupal.org/node/3133343
Release notes snippet
@tbd