- Issue created by @jamsilver
Drupal 10.3.0 introduced a new hook_entity_query_alter() API (see [#3363939] )
Due to the following coincidences:
domain
) plus the suffix _entity
,hook_query_alter()
,The function domain_entity_query_alter()
is considered by core to be an implementation of hook_entity_query_alter()
for the domain
module. (This is being considered an implementation of hook_query_alter()
for the domain_entity
module, as originally intended).
The only reason this does not throw an immediate Fatal Error (at least in my case) is because, of the following coincidences:
domain_entity_query_alter()
starts with quite a general check for method_exists($query, 'getTables')
(added 8 years ago) which fails in the hook_entity_query_alter() case, skipping the method. This is something I discovered while debugging something unrelated. In my situation it doesn't break anything, but I thought I'd bring it to the attention of the module maintainers, as surely it is not the intention for this to be so, it strikes me as quite fragile?
If a getTables method were added to Entity queries for example, it would probably break.
Perhaps it would be a good idea to add this kind of check to the top of the function?
if (!$query instanceof '\Drupal\Core\Entity\Query\Sql\Query') {
return;
}
Active
Code