function rules_entity_view(EntityInterface $entity) has the wrong signature.

According to https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!entity.api... the signature of hook_entity_view() is:

hook_entity_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode, $langcode)

Critical because this breaks code that calls hook_entity_view() when Rules is enabled. Full error message is:

Recoverable fatal error: Argument 1 passed to rules_entity_view() must implement interface Drupal\Core\Entity\EntityInterface, array given in rules_entity_view() (line 39 of modules/rules/rules.module).

rules_entity_view(Array, Object, Object, 'full', 'en')
call_user_func_array('rules_entity_view', Array)
Drupal\Core\Extension\ModuleHandler->invokeAll('entity_view', Array)
Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array)
Drupal\Core\Entity\EntityViewBuilder->build(Array)
call_user_func(Array, Array)
Drupal\Core\Render\Renderer->doRender(Array, )
Drupal\Core\Render\Renderer->render(Array, )
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->fetch(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->lookup(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1)
Stack\StackedHttpKernel->handle(Object, 1, 1)
Drupal\Core\DrupalKernel->handle(Object)

Comments

TR created an issue. See original summary.

  • klausi committed 2655876 on 8.x-3.x
    Issue #2566063: rules_entity_view() has wrong signature
    
klausi’s picture

Status: Active » Fixed

Committed a fix, thanks for reporting!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.