Getting this when triggering an action after saving new content:

Recoverable fatal error: Argument 1 passed to Drupal\\rules\\Plugin\\Condition\\NodeIsPublished::doEvaluate() must implement interface Drupal\\node\\NodeInterface, instance of Drupal\\Core\\Field\\FieldItemList given in /home/www/incurs.us/modules/rules/src/Plugin/Condition/NodeIsPublished.php on line 35

Any ideas?

CommentFileSizeAuthor
#9 Node is published.pdf911.85 KBNeeraj420
#4 Action in the rules.JPG29.82 KBNeeraj420
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

incursus created an issue. See original summary.

TR’s picture

Status: Active » Closed (cannot reproduce)

I can't reproduce this with the current 8.x-3.x-dev.

I created a rule in the UI with the "After saving new content" event (rules_entity_insert:node), add the "Node is published" condition (rules_node_is_published) and configured it on the edit condition form using the data selector and selecting "node" for the Node value. For an action, I used "Show a message on the site" (rules_system_message).

Then I created a new "Article" node (/node/add/article) with the "Published" checkbox selected. After saving the article I was returned to the node view page for my new article, and my system message was shown.

Feel free to reopen if this is still a problem for you and if you can provide some steps to reproduce the issue.

Neeraj420’s picture

Version: 8.x-3.x-dev » 8.x-3.0-alpha3
Status: Closed (cannot reproduce) » Active

Hi,
I am getting this error for following configuration :-
Event : After saving new content
Condition : Node is published
Action : Show message on Site.

However it works perfectly fine for following configuration
Events:
After updating content (rules_entity_update:node)
Condition: Node is published
Action : Show message on Site.

Please note the difference in the Events.

Thanks and Regards,
Neeraj

Neeraj420’s picture

FileSize
29.82 KB

Hey an update.

After updating content (rules_entity_update:node)
Condition: Node is of type test
Action : Add the author of the node to Reviewer group. Configuration is as per attachment.

Is this an issue or i am not typing the correct value of user?

When I am trying to update the Content it is giving the following error message
The website encountered an unexpected error. Please try again later.

TypeError: Argument 1 passed to Drupal\rules\Plugin\Condition\NodeIsOfType::doEvaluate() must implement interface Drupal\node\NodeInterface, string given in Drupal\rules\Plugin\Condition\NodeIsOfType->doEvaluate() (line 40 of modules\rules\src\Plugin\Condition\NodeIsOfType.php).

Drupal\rules\Plugin\Condition\NodeIsOfType->doEvaluate('node', Array)
call_user_func_array(Array, Array) (Line: 83)
Drupal\rules\Core\RulesConditionBase->evaluate() (Line: 109)
Drupal\rules\Plugin\RulesExpression\RulesCondition->executeWithState(Object) (Line: 36)
Drupal\rules\Plugin\RulesExpression\RulesAnd->evaluate(Object) (Line: 73)
Drupal\rules\Engine\ConditionExpressionContainer->executeWithState(Object) (Line: 90)
Drupal\rules\Plugin\RulesExpression\Rule->executeWithState(Object) (Line: 31)
Drupal\rules\Plugin\RulesExpression\ActionSet->executeWithState(Object) (Line: 131)
Drupal\rules\EventSubscriber\GenericEventSubscriber->onRulesEvent(Object, 'rules_entity_update:node', Object) (Line: 108)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('rules_entity_update:node', Object) (Line: 140)
rules_entity_update(Object)
call_user_func_array('rules_entity_update', Array) (Line: 402)
Drupal\Core\Extension\ModuleHandler->invokeAll('entity_update', Array) (Line: 169)
Drupal\Core\Entity\EntityStorageBase->invokeHook('update', Object) (Line: 435)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('update', Object) (Line: 470)
Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, 1) (Line: 320)
Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, 1) (Line: 395)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 796)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 377)
Drupal\Core\Entity\Entity->save() (Line: 286)
Drupal\node\NodeForm->save(Array, Object)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 585)
Drupal\Core\Form\FormBuilder->processForm('node_test_edit_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm('node_test_edit_form', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, 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}()
call_user_func_array(Object, Array) (Line: 153)
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: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Please help, thanks in advance.

TR’s picture

Status: Active » Postponed (maintainer needs more info)

In regards to #3, did you try this with the -dev version? As I reported in #2, I can't reproduce this in the -dev version. If it's fixed in -dev, then this issue should be closed because in Drupal, fixed point releases like 8.x-3.0-alpha3 can't be changed. Development happens in the -dev branch, and bugs get fixed in the -dev branch.

Neeraj420’s picture

Okay, I tried on alpha version.
Yes, this issue is fixed, there was some caching issue, so it was picking the earlier configuration. Following configuration is working fine after clearing the cache.
Event : After saving new content
Condition : Node is published
Action : Show message on Site.

#3 issue got resolved after clearing the cache.

Problem is when i am trying to add the Author of a content to the Role.
Objective is : add the author of the content to role when content is published.
Action is : Add user role
I have tried using following values of User in data selector mode :-

  1. node.uid
  2. node.uid.entity
  3. node.uid.target_id
  4. node.uid.entity.uid
  5. node.uid.entity.uid.value

I get error message as below :-
Expected a entity:user data type for context User but got a list data type instead.

If i enter the value in direct input mode I get the error message as shared in #4

Please help if there is an issue in the code or if there is an issue with the value i am selecting for assigning the author of the content to a role.

Thanks.

Neeraj420’s picture

Category: Bug report » Feature request

It seems this is one of generic error message, on any issue in configuration of rules.

It would be great if the error can have appropriate message, it will help in troubleshooting the issue.

dasjo’s picture

It sounds to me like this should be still a bug report. Could you please summarize the steps to reproduce in the issue summary? Thanks

Neeraj420’s picture

FileSize
911.85 KB

Rules Version : rules-8.x-3.0-alpha3.zip

Patches applied
1) 2694685-52.rules-fix_type_definition_error.patch
2) 2725525-14.fatal_error_call_to_role_id.patch
3) 2800749-9.upcast.patch

I am getting following error message :

The website encountered an unexpected error. Please try again later.
TypeError: Argument 1 passed to Drupal\rules\Plugin\Condition\NodeIsPublished::doEvaluate() must implement interface Drupal\node\NodeInterface, string given in Drupal\rules\Plugin\Condition\NodeIsPublished->doEvaluate() (line 35 of modules\rules\src\Plugin\Condition\NodeIsPublished.php).

Drupal\rules\Plugin\Condition\NodeIsPublished->doEvaluate('test')
call_user_func_array(Array, Array) (Line: 83)
Drupal\rules\Core\RulesConditionBase->evaluate() (Line: 109)
Drupal\rules\Plugin\RulesExpression\RulesCondition->executeWithState(Object) (Line: 36)
Drupal\rules\Plugin\RulesExpression\RulesAnd->evaluate(Object) (Line: 73)
Drupal\rules\Engine\ConditionExpressionContainer->executeWithState(Object) (Line: 90)
Drupal\rules\Plugin\RulesExpression\Rule->executeWithState(Object) (Line: 31)
Drupal\rules\Plugin\RulesExpression\ActionSet->executeWithState(Object) (Line: 131)
Drupal\rules\EventSubscriber\GenericEventSubscriber->onRulesEvent(Object, 'rules_entity_insert:node', Object) (Line: 108)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('rules_entity_insert:node', Object) (Line: 124)
rules_entity_insert(Object)
call_user_func_array('rules_entity_insert', Array) (Line: 402)
Drupal\Core\Extension\ModuleHandler->invokeAll('entity_insert', Array) (Line: 169)
Drupal\Core\Entity\EntityStorageBase->invokeHook('insert', Object) (Line: 435)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('insert', Object) (Line: 470)
Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, ) (Line: 320)
Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, ) (Line: 395)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 796)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 377)
Drupal\Core\Entity\Entity->save() (Line: 286)
Drupal\node\NodeForm->save(Array, Object)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 585)
Drupal\Core\Form\FormBuilder->processForm('node_page_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm('node_page_form', Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object) (Line: 113)
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}()
call_user_func_array(Object, Array) (Line: 153)
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: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

TR’s picture

Category: Feature request » Support request
Priority: Major » Normal
Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

No no no. You keep changing the event, changing the condition, changing the action, first you say it's working (#6), then you present an entirely different set of event/condition/action and say it's not working, then you start mixing in a custom content type which you fail to mention, and now you're entering things like "Test2" for the "Node" context value - of course that doesn't work, it should be "node" like I explicitly said in #2.

At this point, we are so far away from the original post, and you have presented so many different problems with different combinations of events/conditions/actions that your issues are a moving target that will never be fixed. I'm closing this again because you have confused the issue with so many unrelated problems that it's impossible to figure out what you're doing.

If you want some help, then you need to provide the *exact* steps for someone else to reproduce the error - that means simplifying the problem (NO custom content types) and following the working steps already provided to you in #2. After getting it to work like #2, change ONE thing at a time and see if it keeps working - if your change breaks something, then suspect it's your change and try to figure out why. Then if it is still broken after trying to get that one change working, then open a new issue and PROVIDE EXACT STEPS to reproduce. Like I did in #2. Tell us what the event/condition/action is, tell us what you entered for each of the inputs, DON'T keep changing the event or the condition or the action every time you make a new post, and DON'T use custom content types or other things that can't be reproduced - stick with the built-in types that every site has. Many time you will find that listing the steps for others makes it clear to you where you made a mistake, or at the very least helps you figure out exactly what question needs to be asked.

I am closing this, again, as "Cannot reproduce" because as I said in #2, I cannot reproduce this. You agreed in #6, where you said "this issue is fixed". But then you moved on to an entirely different problem. If you have a new problem, open a new issue.

Neeraj420’s picture

Thanks TR.

I agree. #6 it cannot be reproduced.

However if I put anything this is not expected, it should give me an error which should be understandable. see comment #7.

e.g. if under the node type value has to be node and not Test2 as i mentioned in my case. What I was expecting was to have an error message which says atleast Test2 is an invalid value instead of giving any generic error message.