I get this error when accessing unit entities in views:
ArgumentCountError: Too few arguments to function bat_unit_query_bat_unit_type_access_alter(), 0 passed and exactly 1 expected in bat_unit_query_bat_unit_type_access_alter()
This is the entire call stack:
#0 [internal function]: bat_unit_query_bat_unit_type_access_alter()
#1 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(409): call_user_func_array(Object(Closure), Array)
#2 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(388): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object(Closure), 'bat_unit')
#3 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(416): Drupal\Core\Extension\ModuleHandler->invokeAllWith('query_bat_unit_...', Object(Closure))
#4 /app/web/modules/contrib/bat/bat.module(129): Drupal\Core\Extension\ModuleHandler->invokeAll('query_bat_unit_...')
#5 [internal function]: bat_entity_access(Object(Drupal\bat_unit\Entity\UnitType), 'view', Object(Drupal\Core\Session\AccountProxy))
#6 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(409): call_user_func_array(Object(Closure), Array)
#7 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(388): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object(Closure), 'bat')
#8 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(416): Drupal\Core\Extension\ModuleHandler->invokeAllWith('entity_access', Object(Closure))
#9 /app/web/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php(100): Drupal\Core\Extension\ModuleHandler->invokeAll('entity_access', Array)
#10 /app/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php(739): Drupal\Core\Entity\EntityAccessControlHandler->access(Object(Drupal\bat_unit\Entity\UnitType), 'view', Object(Drupal\Core\Session\AccountProxy), true)
#11 /app/web/core/modules/views/src/Plugin/views/field/RenderedEntity.php(138): Drupal\Core\Entity\ContentEntityBase->access('view', NULL, true)
#12 /app/web/core/modules/views/src/Plugin/views/field/FieldPluginBase.php(1196): Drupal\views\Plugin\views\field\RenderedEntity->render(Object(Drupal\views\ResultRow))
#13 /app/web/core/modules/views/views.theme.inc(238): Drupal\views\Plugin\views\field\FieldPluginBase->advancedRender(Object(Drupal\views\ResultRow))
#14 [internal function]: template_preprocess_views_view_field(Array, 'views_view_fiel...', Array)
#15 /app/web/core/lib/Drupal/Core/Theme/ThemeManager.php(261): call_user_func_array('template_prepro...', Array)
#16 /app/web/core/lib/Drupal/Core/Render/Renderer.php(480): Drupal\Core\Theme\ThemeManager->render('views_view_fiel...', Array)
#17 /app/web/core/lib/Drupal/Core/Render/Renderer.php(240): Drupal\Core\Render\Renderer->doRender(Array, false)
#18 /app/web/core/modules/views/src/Plugin/views/field/FieldPluginBase.php(1784): Drupal\Core\Render\Renderer->render(Array)
#19 /app/web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(765): Drupal\views\Plugin\views\field\FieldPluginBase->theme(Object(Drupal\views\ResultRow))
#20 [internal function]: Drupal\views\Plugin\views\style\StylePluginBase->elementPreRenderRow(Array)
#21 /app/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(111): call_user_func_array(Array, Array)
#22 /app/web/core/lib/Drupal/Core/Render/Renderer.php(858): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'exception', 'Drupal\\Core\\Ren...')
#23 /app/web/core/lib/Drupal/Core/Render/Renderer.php(421): Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array)
#24 /app/web/core/lib/Drupal/Core/Render/Renderer.php(240): Drupal\Core\Render\Renderer->doRender(Array, false)
#25 /app/web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(704): Drupal\Core\Render\Renderer->render(Array)
#26 /app/web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(570): Drupal\views\Plugin\views\style\StylePluginBase->renderFields(Array)
#27 /app/web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(461): Drupal\views\Plugin\views\style\StylePluginBase->renderGrouping(Array, Array, true)
#28 /app/web/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(2174): Drupal\views\Plugin\views\style\StylePluginBase->render(Array)
#29 /app/web/core/modules/views/src/ViewExecutable.php(1548): Drupal\views\Plugin\views\display\DisplayPluginBase->render()
#30 /app/web/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(2464): Drupal\views\ViewExecutable->render()
#31 /app/web/core/modules/views/src/ViewExecutable.php(1677): Drupal\views\Plugin\views\display\DisplayPluginBase->preview()
#32 /app/web/core/modules/views/src/Element/View.php(66): Drupal\views\ViewExecutable->preview('default', Array)
#33 [internal function]: Drupal\views\Element\View::preRenderViewElement(Array)
#34 /app/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(111): call_user_func_array(Array, Array)
#35 /app/web/core/lib/Drupal/Core/Render/Renderer.php(858): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'exception', 'Drupal\\Core\\Ren...')
#36 /app/web/core/lib/Drupal/Core/Render/Renderer.php(421): Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array)
#37 /app/web/core/lib/Drupal/Core/Render/Renderer.php(493): Drupal\Core\Render\Renderer->doRender(Array)
#38 /app/web/core/lib/Drupal/Core/Render/Renderer.php(240): Drupal\Core\Render\Renderer->doRender(Array, false)
#39 /app/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(238): Drupal\Core\Render\Renderer->render(Array, false)
#40 /app/web/core/lib/Drupal/Core/Render/Renderer.php(627): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#41 /app/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(239): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#42 /app/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(128): Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#43 /app/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#44 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#45 /app/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#46 /app/vendor/symfony/http-kernel/HttpKernel.php(186): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view')
#47 /app/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#48 /app/web/modules/contrib/bat_api/src/StackMiddleware/BatApiMiddleware.php(39): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#49 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Drupal\bat_api\StackMiddleware\BatApiMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#50 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#51 /app/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#52 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#53 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#54 /app/web/modules/contrib/services/src/StackMiddleware/FormatSetter.php(45): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#55 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\services\StackMiddleware\FormatSetter->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#56 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#57 /app/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#58 /app/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#59 /app/web/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#60 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#61 {main}
This seems to be caused by these calls to moduleHandler()->invokeAll() without arguments
...
if (Drupal::moduleHandler()->invokeAll('query_' . $entity_type . '_alter') ||
Drupal::moduleHandler()->invokeAll('query_' . $entity_type . '_access_alter')) {
if (Drupal::moduleHandler()->invokeAll('query_' . $entity_type . '_alter')) {
...
what about using hasImplementations() to check if alter functions exist?