Since a day or two, I'm suddenly getting errors in a custom test I'm running on a contrib module which exposes a plugin for Rabit hole.

The error on the test bot is this: Exception: TypeError: Argument 1 passed to Drupal\rabbit_hole\Plugin\RabbitHoleBehaviorPluginBase::performAction() must be an instance of Drupal\Core\Entity\Entity, instance of Drupal\node\Entity\Node given, called in /var/www/html/modules/contrib/rabbit_hole/src/BehaviorInvoker.php on line 126
Drupal\rabbit_hole\Plugin\RabbitHoleBehaviorPluginBase->performAction()() (Line: 17)

Weird thing, I can't reproduce this locally, the test runs fine then.

Example failure on the testbot: https://dispatcher.drupalci.org/job/drupal_contrib/343162/testReport/jun...

Just letting you know, not exactly sure what goes wrong here.

Comments

swentel created an issue. See original summary.

mishac’s picture

I started having a very similar issue, but in a different function, when I updated to drupal 8.7-alpha1:

TypeError: Argument 2 passed to Drupal\rabbit_hole\FormManglerService::addRabbitHoleOptionsToEntityForm() must be an instance of Drupal\Core\Entity\Entity, instance of Drupal\node\Entity\Node given, called in /app/web/modules/contrib/rabbit_hole/rabbit_hole.module on line 68 in Drupal\rabbit_hole\FormManglerService->addRabbitHoleOptionsToEntityForm() (line 81 of modules/contrib/rabbit_hole/src/FormManglerService.php).

mishac’s picture

StatusFileSize
new1.83 KB

Here's a patch that fixes the issue for me, on beta 5.

jibran’s picture

Title: Suddenly Test failures » Change Entity typehint to EntityInterface
Category: Support request » Bug report
Priority: Normal » Major
Status: Active » Needs review
StatusFileSize
new6.3 KB

Here is the patch to fix the issue described in IS and #2

jibran’s picture

StatusFileSize
new7.81 KB

Missed couple of usages.

mishac’s picture

After a few min of testing, patch in #5 works for me so far with 1.x-dev on Drupal 8.7.0-alpha-1. No more WSoDs!

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Ok, can we mark this RTBC?

upchuk’s picture

Yeah, this is happening because of #1883744: Convert Entity to EntityBase for consistency with ContentEntityBase and ConfigEntityBase. So makes sense to always type-hint the interface rather than a base class.

The patch looks good.

drcolossos’s picture

Works as expected! RTBC!

WidgetsBurritos’s picture

+1, I can also confirm the patch in #5 resolves this issue.

dylan donkersgoed’s picture

Status: Reviewed & tested by the community » Fixed

I merged this in, thanks for the patch.

train’s picture

Just for giggles I manually applied these changes to 1.0-beta5 and they worked in D8.7.0.

adrianm6254’s picture

I was able to apply 3038539-5.patch successfully on D8.7.0.

Works like a charm.

markdorison’s picture

Priority: Major » Critical

Updating to Drupal 8.7.0 without this patch applied resulted in a PHP error. I can confirm that this patch resolved the error, which I will include here for searchability:

TypeError: Argument 1 passed to Drupal\rabbit_hole\Plugin\RabbitHoleBehaviorPluginBase::performAction() must be an instance of Drupal\Core\Entity\Entity, instance of Drupal\node\Entity\Node given, called in /app/web/modules/contrib/rabbit_hole/src/BehaviorInvoker.php on line 126 in Drupal\rabbit_hole\Plugin\RabbitHoleBehaviorPluginBase->performAction() (line 17 of /app/web/modules/contrib/rabbit_hole/src/Plugin/RabbitHoleBehaviorPluginBase.php) #0

Could a new release be cut with this latest fix? I bet it would eliminate a lot of confusion for users upgrading Drupal core.

shepparddigital’s picture

I updated 7 sites to 8.7.0 last night, and this issue occurred on all of them. I can confirm this patch resolved the issue.

If this problem was apparent during earlier versions, why didn't this patch make it into the latest release? It would have avoided all of this confusion.

anybody’s picture

Thank you! New beta6 release would be nice because 8.7 is out and everyone using it will run into the problem! Is that possible?

hugovk’s picture

Rabbit Hole 8.x-1.0-beta6 has been released with this fix. I've verified the fix with Drupal 8.7. Thanks all!

https://www.drupal.org/project/rabbit_hole/releases/8.x-1.0-beta6

anybody’s picture

Thanks!!

Status: Fixed » Closed (fixed)

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

akshita’s picture

After upgrading to 8.7.1, I ended up with the below error:

The website encountered an unexpected error. Please try again later.
TypeError: Argument 1 passed to Drupal\rabbit_hole\Plugin\RabbitHoleBehaviorPluginBase::performAction() must be an instance of Drupal\Core\Entity\Entity, instance of Drupal\node\Entity\Node given, called in /var/www/docroot/modules/contrib/rabbit_hole/src/BehaviorInvoker.php on line 126 in Drupal\rabbit_hole\Plugin\RabbitHoleBehaviorPluginBase->performAction() (line 17 of modules/contrib/rabbit_hole/src/Plugin/RabbitHoleBehaviorPluginBase.php).

The above patch helped me to get rid off of the error message and the site was up but "Rabbit Hole settings" @page redirect is not working anymore. I tried the other options but none of them were working.

Here is the redirect path: [media:field_media_file:entity:url] (redirecting the entity page to the file)

Any help is appreciated.

akshita’s picture

StatusFileSize
new243.82 KB
mturner20’s picture

I can confirm that the patch from #5 worked for me on version 8.x-1.x-dev! Thanks jibran!

isa.bel’s picture

StatusFileSize
new9.26 KB

Hello everyone,

Even tho this issue is fixed, for me this problem wasn't solve by updating rabbit_hole module and I'm on Drupal version 8.7.3.
So, I've tried to apply the patch from #5 and it gave me some conflicts.
Then I've made some changes on it, that's why I'm uploading it here.
Hope it helps someone else.

Thank you.

isa.bel’s picture

StatusFileSize
new8.24 KB
new8.24 KB

Apologies, disregard #24. Added diffs not related to this module.

stevenx’s picture

Upgrade to rabbit_hole:^1.0 fixed it for me

zyla’s picture

Same for me, upgrade rabbit_hole to 1.0.0-beta6 fixed it.

Gnanasampandan Velmurgan’s picture

After upgrading drupal core to 8.7.6, I ended up with the below error:
TypeError: Argument 2 passed to Drupal\rabbit_hole\FormManglerService::addRabbitHoleOptionsToEntityForm() must be an instance of Drupal\Core\Entity\Entity, instance of Drupal\node\Entity\Node given, called in /var/www/html/modules/rabbit_hole/rabbit_hole.module on line 67 in Drupal\rabbit_hole\FormManglerService->addRabbitHoleOptionsToEntityForm() (line 81 of /var/www/html/modules/rabbit_hole/src/FormManglerService.php) #0 /var/www/html/modules/rabbit_hole/rabbit_hole.module(67): Drupal\rabbit_hole\FormManglerService->addRabbitHoleOptionsToEntityForm(Array, Object(Drupal\node\Entity\Node), Object(Drupal\Core\Form\FormState), 'node_one_column...') #1 /var/www/html/core/lib/Drupal/Core/Extension/ModuleHandler.php(539): rabbit_hole_form_alter(Array, Object(Drupal\Core\Form\FormState), 'node_one_column...') #2 /var/www/html/core/lib/Drupal/Core/Form/FormBuilder.php(835):

The above #5 patch helped me works as perfect.

rakesh.gectcr’s picture

Me too got the same error after updating the Drupal core to 8.7.x

The website encountered an unexpected error. Please try again later.
TypeError: Argument 2 passed to Drupal\rabbit_hole\FormManglerService::addRabbitHoleOptionsToEntityForm() must be an instance of Drupal\Core\Entity\Entity, instance of Drupal\node\Entity\Node given, called in /docroot/modules/contrib/rabbit_hole/rabbit_hole.module on line 67 in Drupal\rabbit_hole\FormManglerService->addRabbitHoleOptionsToEntityForm() (line 81 of modules/contrib/rabbit_hole/src/FormManglerService.php).
Drupal\rabbit_hole\FormManglerService->addRabbitHoleOptionsToEntityForm(Array, Object, Object, 'node_page_form') (Line: 67)
rabbit_hole_form_alter(Array, Object, 'node_page_form') (Line: 539)
Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'node_page_form') (Line: 835)
Drupal\Core\Form\FormBuilder->prepareForm('node_page_form', Array, Object) (Line: 277)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 61)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object) (Line: 129)
Drupal\node\Controller\NodeController->add(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 57)
Drupal\shield\ShieldMiddleware->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

my module version was "drupal/rabbit_hole": "^1.0@beta",

Updated the module to rabbit_hole 8.x-1.0-beta6 Helps me to resolve the issue.

shreya_r’s picture

I updated from Drupal 8.6.17 to 8.7.7.

I got this error and I wasn't able to edit content-

TypeError: Argument 2 passed to Drupal\rabbit_hole\FormManglerService::addRabbitHoleOptionsToEntityForm() must be an instance of Drupal\Core\Entity\Entity, instance of Drupal\node\Entity\Node given, called in /app/web/modules/contrib/rabbit_hole/rabbit_hole.module on line 68 in Drupal\rabbit_hole\FormManglerService->addRabbitHoleOptionsToEntityForm() (line 81 of modules/contrib/rabbit_hole/src/FormManglerService.php)

Upgrade to rabbit_hole:^1.0 fixed it for me

davi.uezono’s picture

I was using Drupal 8.6.17 and rabbit_hole 1.0-beta4.
I've just updated to Drupal 8.7.11 and that's when I got to this error.
Upgrading it to 1.0-beta6 solved everything.