Problem/Motivation
When using Entity Field Query to query a revisionable entity and calling:$query->allRevisions()
If you set a condition on an entity reference where the target entity type DOES NOT support revisions then the you get a fatal error form \Drupal\Core\Entity\Query\Sql\Tables::ensureEntityTable because \Drupal\Core\Entity\Query\Sql\Tables::addField will attempt to use the revision tables of the target entity even though they do not exist.
The simplest way to demonstrate this is to write a Entity Query to find all the node revisions that have a term in field_tags where the name equals a value.
$query = $this->entityTypeManager()->getStorage('node')->getQuery('AND');
$query->condition('field_tags.entity.name', $search_str);
$query->allRevisions();
$ids = $query->execute();
This code throws the error.
Here is github demo repo that provides a module that demonstrates this problem.
Proposed resolution
Instead of directly using the "allRevision" metadata from the query use an $use_revisions variable which will be update if \Drupal\Core\Entity\Query\Sql\Tables::addField
determines the field is using a "valid relationship" through an entity reference field.
Remaining tasks
Complete patch
Write Tests
User interface changes
None
API changes
None
Data model changes
None