Closed (works as designed)
Project:
Rules
Version:
8.x-3.x-dev
Component:
Rules Core
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
18 Jul 2016 at 17:35 UTC
Updated:
24 Jun 2019 at 23:30 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
sukanya.ramakrishnan commentedComment #3
gnaman commentedHi,
I have the same problem.
I done throubleshooting and I detected that args passed are:
array(2) {
["node"]=> string(4) "node"
["types"]=> array(1) { [0]=> string(7) "article" }
}
I believe that node param is bad, because the funtion is awaiting any structure of type $node. Of this reason when the function tries to execute $node->getType() drupal dies.
could you help us?
Thanks
Comment #4
juliencarnot commentedReproduced with 8.x-3.0-alpha2. Haven't found a clear explanation of the data selection UI (or a description of what should work in this alpha version) so I could very well be trying something wrong, but it seems I'm not the only one...
Comment #5
ktch_my commentedGetting the same error, more info below:
Version: 8.x-3.0-alpha2
Event : After saving new content
Condition : WITH or WITHOUT node of type (to make sure node type is the culprit, but error occur anyway)
Action : Send email
Comment #6
intrafusionI was having the same problem, but found that if you switch to Entity is of bundle, you have an option to select both the entity type and bundle, in the OP's instance they would enter:
ENTITY: node
TYPE: node
BUNDLE: idea
Comment #7
kniekel commentedThank you @intrafusion. I tried that, but I still get the error "The website encountered an unexpected error. Please try again later." - which is of course not very helpful
Comment #8
kniekel commentedOr in case this helps:
TypeError: Argument 1 passed to Drupal\rules\Plugin\Condition\EntityIsOfBundle::doEvaluate() must implement interface Drupal\Core\Entity\EntityInterface, string given in Drupal\rules\Plugin\Condition\EntityIsOfBundle->doEvaluate() (line 49 of /www/htdocs/w00ad09e/d8/modules/rules/src/Plugin/Condition/EntityIsOfBundle.php) #0 [internal function]: Drupal\rules\Plugin\Condition\EntityIsOfBundle->doEvaluate('node', 'node', 'termin') #1 /www/htdocs/w00ad09e/d8/modules/rules/src/Core/RulesConditionBase.php(69): call_user_func_array(Array, Array) #2 /www/htdocs/w00ad09e/d8/modules/rules/src/Plugin/RulesExpression/RulesCondition.php(109): Drupal\rules\Core\RulesConditionBase->evaluate() #3 /www/htdocs/w00ad09e/d8/modules/rules/src/Plugin/RulesExpression/RulesAnd.php(36): Drupal\rules\Plugin\RulesExpression\RulesCondition->executeWithState(Object(Drupal\rules\Engine\ExecutionState)) #4 /www/htdocs/w00ad09e/d8/modules/rules/src/Engine/ConditionExpressionContainer.php(73): Drupal\rules\Plugin\RulesExpression\RulesAnd->evaluate(Object(Drupal\rules\Engine\ExecutionState)) #5 /www/htdocs/w00ad09e/d8/modules/rules/src/Plugin/RulesExpression/Rule.php(90): Drupal\rules\Engine\ConditionExpressionContainer->executeWithState(Object(Drupal\rules\Engine\ExecutionState)) #6 /www/htdocs/w00ad09e/d8/modules/rules/src/Plugin/RulesExpression/ActionSet.php(31): Drupal\rules\Plugin\RulesExpression\Rule->executeWithState(Object(Drupal\rules\Engine\ExecutionState)) #7 /www/htdocs/w00ad09e/d8/modules/rules/src/EventSubscriber/GenericEventSubscriber.php(131): Drupal\rules\Plugin\RulesExpression\ActionSet->executeWithState(Object(Drupal\rules\Engine\ExecutionState)) #8 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): Drupal\rules\EventSubscriber\GenericEventSubscriber->onRulesEvent(Object(Drupal\rules\Event\EntityEvent), 'rules_entity_in...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) #9 /www/htdocs/w00ad09e/d8/modules/rules/rules.module(124): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('rules_entity_in...', Object(Drupal\rules\Event\EntityEvent)) #10 [internal function]: rules_entity_insert(Object(Drupal\node\Entity\Node)) #11 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/Extension/ModuleHandler.php(402): call_user_func_array('rules_entity_in...', Array) #12 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/Entity/EntityStorageBase.php(169): Drupal\Core\Extension\ModuleHandler->invokeAll('entity_insert', Array) #13 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(418): Drupal\Core\Entity\EntityStorageBase->invokeHook('insert', Object(Drupal\node\Entity\Node)) #14 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/Entity/EntityStorageBase.php(470): Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('insert', Object(Drupal\node\Entity\Node)) #15 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(304): Drupal\Core\Entity\EntityStorageBase->doPostSave(Object(Drupal\node\Entity\Node), false) #16 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/Entity/EntityStorageBase.php(395): Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object(Drupal\node\Entity\Node), false) #17 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(761): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\node\Entity\Node)) #18 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/Entity/Entity.php(364): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object(Drupal\node\Entity\Node)) #19 /www/htdocs/w00ad09e/d8/core/modules/node/src/NodeForm.php(356): Drupal\Core\Entity\Entity->save() #20 [internal function]: Drupal\node\NodeForm->save(Array, Object(Drupal\Core\Form\FormState)) #21 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/Form/FormSubmitter.php(111): call_user_func_array(Array, Array) #22 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/Form/FormSubmitter.php(51): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState)) #23 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/Form/FormBuilder.php(585): Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object(Drupal\Core\Form\FormState)) #24 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/Form/FormBuilder.php(314): Drupal\Core\Form\FormBuilder->processForm('node_termin_for...', Array, Object(Drupal\Core\Form\FormState)) #25 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/Entity/EntityFormBuilder.php(48): Drupal\Core\Form\FormBuilder->buildForm('node_termin_for...', Object(Drupal\Core\Form\FormState)) #26 /www/htdocs/w00ad09e/d8/core/modules/node/src/Controller/NodeController.php(113): Drupal\Core\Entity\EntityFormBuilder->getForm(Object(Drupal\node\Entity\Node)) #27 [internal function]: Drupal\node\Controller\NodeController->add(Object(Drupal\node\Entity\NodeType)) #28 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #29 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/Render/Renderer.php(574): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #30 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #31 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #32 [internal function]: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #33 /www/htdocs/w00ad09e/d8/vendor/symfony/http-kernel/HttpKernel.php(139): call_user_func_array(Object(Closure), Array) #34 /www/htdocs/w00ad09e/d8/vendor/symfony/http-kernel/HttpKernel.php(62): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #35 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #36 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #37 /www/htdocs/w00ad09e/d8/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #38 /www/htdocs/w00ad09e/d8/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #39 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #40 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #41 /www/htdocs/w00ad09e/d8/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #42 /www/htdocs/w00ad09e/d8/core/lib/Drupal/Core/DrupalKernel.php(652): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #43 /www/htdocs/w00ad09e/d8/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #44 {main}.Comment #9
rjjakes commentedThis may be related to https://www.drupal.org/node/2824360 depending on the errors you're getting.
Comment #10
kniekel commentedThank you very much rjjakes. The error has gone with that patch. But it seems I can't get a reaction rule on "after saving new content" to do anything at all ...
Should we mark this thread as a duplicate of https://www.drupal.org/node/2824360 or are they still different?
Comment #11
rjjakes commentedI"d suggest we do the work on that other thread. So if you can mark this one duplicate and add your comment on the other one, I can work on the patch there.
Comment #12
hkirsman commentedThe patch from https://www.drupal.org/node/2824360 didn't help for me.
Comment #13
hkirsman commentedSame problem with "Condition: Entity is of bundle". Tried both alpha2 and dev.
Comment #14
shabana.navas commentedNot sure if this is related but the condition 'Entity is of bundle' seems to not trigger at all. I've got a rule that triggers on node creation and sends an email. The only condition I have is the entity is of bundle one with the following params:
Entity: node
Type: node
Bundle: page
The condition never seems to trigger and the email is being sent out just fine. I put in debug statements in Rules\src\Plugin\Condition\EntityIsOfBundle.php in the doEvaluation() function but nothing is printed and the function is not even triggered it seems.
Comment #15
johnreytanquinco commentedAny update for this? Is sad that rules doesnt seem to be working properly even with simple configuration. Created my own thread. https://www.drupal.org/project/rules/issues/2929588
Comment #16
magick93 commentedAlso having same problem
Comment #17
nkoporecHaving the same problem here, running Drupal 8.5 and latest dev branch of rules.
Comment #18
nkoporecComment #19
guillaumeduveau@nkoporec It makes no sense changing the branch of this issue to 8.x-1.x...
Comment #20
baikho commentedI'm also getting this error on Drupal 8.5.3 with the latest from Rules 3.x-dev unless I use the data selection mode. The working setup for
Condition: Node is of type:* NODE - Data selector: node (with data selection mode)
* CONTENT TYPES - Value: article (with direct input mode)
works for both node events with above mentioned versions of Drupal & Rules (& after cache clear):
* After saving new content (rules_entity_insert:node)
* After updating content (rules_entity_update:node)
Not sure but I think we need to allow the condition plugins to fail gracefully when
doEvaluate()is called fromRulesConditionBase::evaluate()? This is regarding line 69 inDrupal\rules\Core\RulesConditionBase:See attached patch for a fix to get rid of the uncaught error.
Comment #22
baikho commentedTest failure fixed in new patch. Updated the
InvalidArgumentExceptiontest inDrupal\Tests\rules\Unit\Integration\Condition\UserHasRoleTest& added aTypeErrortest to theDrupal\Tests\rules\Unit\Integration\Condition\NodeIsOfTypeTestas well (the one being replicated in this issue).Comment #23
fonant commentedI hit this, with "node" as the node selector but with direct input mode. So it was a string. Changing to data selection mode fixed the problem.
Comment #24
drseussofporn commented@Baik_Ho and @fonant: Holy hell, I love both of you. I have been hitting my head against a brick wall with Rules for Drupal 8 since early in development. And the whole time the secret was making sure that the correct data selection mode was used (even when entering items manually). Just like that, Rules works.
Comment #25
tr commentedTo summarize, the solution to the original problem is to use the Data selector mode to enter "node" as the first parameter of the " Node is of type" condition - don't use the (default) direct input mode. This solution is mentioned in #20, #23, and #24.
This problem and the solution is explained more compactly and with no extraneous information in #2998793: Node is of Type error.
@Baik Ho: In regards to the patch from #22:
Yes, we need better error handling to deal with bad input. Your patch is a good start. I think the bad input can be mostly avoided by front-end validation, which is part of the work that remains to be done on the still-incomplete UI. (See milestone 3 in #2245015: [META] Rules 8.x Roadmap). Specifically, the direct input mode should only be available when the context parameter can accept text input, otherwise the data selector mode should be the only choice. Likewise, the data selector should only display data that is type-appropriate - it should not let you choose a string value when a NodeInterface value is required. (When upcasting is implemented, then we would also accept an integer like a nid when a NodeInterface is required, and upcasting would automatically load the appropriate Node given that nid.).
Regardless, I think your patch from #22 should be in its own issue - if you could create that new issue and re-post your patch there I'd appreciate it.
I'm leaving this current issue open for the time being so we don't lose track of your patch, but otherwise I consider this issue closed and fixed.
Comment #26
boby_ui commentedconfirmed that #22 works out, thank you!! @baik ho
Comment #27
rodmarasi commentedComment #28
tr commented@boby_ui
@rodmarasi
Huh? Did either of you read what I wrote in #25 and in #2998793: Node is of Type error which I referenced in #25?
Comment #29
boby_ui commented@TR somehow I used the patch and its not throwing anymore of that error....
Comment #30
tr commentedThis will be addressed by #2723259: Allow single-valued data selector input to be passed as an array for 'multiple' context fields