Change record: https://www.drupal.org/node/2708973
If an entity query uses
->allRevisions() the base_table and data_table are not queried, only the revision_table and revision_data_table are. This means fields that are not revisionable are not able to be queried.
Take this hypothetical example:
$this->entityTypeManager->getStorage($entity_type_id) ->getQuery() ->allRevisions() ->condition('foo', 'bar') ->execute();
If I have added a field
foo to all entity types, which is not revisionable, and I want to return all revisions of a given entity type where
bar. This would throw an error such as:
Uncaught PHP Exception Drupal\\Core\\Entity\\Query\\QueryException: "'foo' not found" at core/lib/Drupal/Core/Entity/Query/Sql/Tables.php line 25
Why is this so important?
This is currently blocking Multiversion and Workbench Moderation from working together. Multiversion makes all content entities revisionable, but not all fields revisionable. It even adds non-revisionable fields to revisionable entities, because sometimes it makes sense, especially for "meta" kinds of data. For example in Multiversion the workspace an entity belongs to is a non-revisionable field, we don't want to allow different revisions of an entity to belong to different workspaces, this will cause all kinds of pain.
Workbench Moderation only really cares about revisions, it even allows you to create forward revisions, these are revisions newer than the current default revision. Therefore when looking for the newest revision Workbench Moderation uses an
allRevisions() query. Multiversion hooks into this and adds a condition for the workspace field and which is when we get a
Uncaught PHP Exception Drupal\\Core\\Entity\\Query\\QueryException: "'workspace' not found" issue.
I expect there will be many more cases where this will come up in the future.