Problem/Motivation

I have a Software type that has a Link field for an RSS/Atom feed path, and a Rule that, on the saving of Software content, creates a Feed item with that feed path.

This doesn't work though with an 'anon submission to draft' workflow, because when the content is saved not by myself but by an anon user, they don't have permission to create a feed, which I don't quite mind; in instances where the Software content is created by anon, I'd like to decide to create the feed, but when I change a Software from draft to published, I'm not saving it, I'm updating it, so the Rule doesn't trigger.

So I have created a newer Rule that does the same but when a saved piece of content is updated. The problem is that I cannot figure out a Rules condition that can check if the Feed item exists for that Software content, so as to avoid creating duplicate Feed items on every update.

In trying to setup do a "Data value is empty" and data to check as "feeds_feed_created.fid", I get back "Data selector feeds_feed_created.fid for context Data to check is invalid. Unable to get variable 'feeds_feed_created'; it is not defined.". It appears this is the same for anything under "feeds_feed_created."

I was unsure if any existing issue relates to this, or whether there might be another step I can take to hook this together?

The Feed item gets an entity reference field that points back to the Software entity (setup as part of the rule).

I then tried adding a Feed entity reference field to the Software type so it can be a bidirectional thing, but when I try "Parameters: data: node.field_feed.entity.fid.value", then manually setting it on an existing Software to an existing Feed, that saved, but when trying to save something without a related Feed, it gives the error;

Drupal\typed_data\Exception\InvalidArgumentException: The parent property is not a list or a complex structure at 'field_feed.entity'. in Drupal\typed_data\DataFetcher->fetchDataBySubPaths() (line 79 of /var/www/html/modules/typed_data/src/DataFetcher.php).
Drupal\Core\Entity\EntityStorageException: The parent property is not a list or a complex structure at 'field_feed.entity'. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 810 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Drupal\rules\Context\ExecutionState->fetchDataByPropertyPath() (Line: 62)
Drupal\rules\Plugin\RulesExpression\ConditionExpression->prepareContext() (Line: 119)
Drupal\rules\Plugin\RulesExpression\ConditionExpression->executeWithState() (Line: 38)
Drupal\rules\Plugin\RulesExpression\AndExpression->evaluate() (Line: 79)
Drupal\rules\Engine\ConditionExpressionContainer->executeWithState() (Line: 112)
Drupal\rules\Plugin\RulesExpression\RuleExpression->executeWithState() (Line: 33)
Drupal\rules\Plugin\RulesExpression\ActionSetExpression->executeWithState() (Line: 147)
Drupal\rules\EventSubscriber\GenericEventSubscriber->onRulesEvent()
call_user_func() (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 183)
rules_entity_update()
call_user_func_array() (Line: 403)
Drupal\Core\Extension\ModuleHandler->invokeAll() (Line: 201)
Drupal\Core\Entity\EntityStorageBase->invokeHook() (Line: 800)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook() (Line: 530)
Drupal\Core\Entity\EntityStorageBase->doPostSave() (Line: 685)
Drupal\Core\Entity\ContentEntityStorageBase->doPostSave() (Line: 455)
Drupal\Core\Entity\EntityStorageBase->save() (Line: 801)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (Line: 339)
Drupal\Core\Entity\EntityBase->save() (Line: 270)
Drupal\node\NodeForm->save()
call_user_func_array() (Line: 113)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 593)
Drupal\Core\Form\FormBuilder->processForm() (Line: 321)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult() (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 57)
Drupal\Core\StackMiddleware\Session->handle() (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 49)
Drupal\remove_http_headers\StackMiddleware\RemoveHttpHeadersMiddleware->handle() (Line: 23)
Stack\StackedHttpKernel->handle() (Line: 705)
Drupal\Core\DrupalKernel->handle() (Line: 19)

I think I copied the right error from the right tabs / log messages there, it happened with a few different data selector varients, though maybe I missed something(?)

Any thoughts on how to proceed would be welcome :)

Comments

mxmilkiib created an issue. See original summary.

TR’s picture

Please try to narrow down the problem and simplify it - there are simply too many unknowns and too many site-specific details here for me to reproduce your problem. And there are also too many problems that you've mentioned - try dealing with one at a time.

For example, "The parent property is not a list or a complex structure" sounds a lot like #2994050: rules_data_is_empty can't check if fields are empty. Please search open AND closed issues, as the closed issues contain a lot of useful information.

In general, when debugging work from event to condition to action, testing each along the way and using the "Show a system message" action to display any values that you're trying to use, for example display {{ node.field_feed.entity.fid.value }} to see what that's set to. Also you can turn on Rules debugging to see how your rules are being evaluated.

mxmilkiib’s picture

Status: Active » Closed (duplicate)

I did search All, naturally, but apparently I searched for the wrong things in quotes. I (am pretty sure I) only mentioned two issues, and AFAICT, the non-matching but related keywords on #2994050 appear to show the two issues are actually related, so I'll close this as a dupe for now.