Following some recent commits to the Rules module we have a test failure:

1) Drupal\Tests\scheduler\Functional\SchedulerRulesEventsTest::testRulesEvents

Argument 2 passed to Drupal\rules\Engine\RulesComponent::addContextDefinition() must implement interface Drupal\rules\Context\ContextDefinitionInterface, array given, called in modules/rules/src/Engine/RulesComponent.php on line 175 and defined

Comments

jonathan1055 created an issue. See original summary.

jonathan1055’s picture

The failure is in tests/src/Functional/SchedulerRulesEventsTest.php, line 72 when trying to save a reaction rule.

The tests do not fail on drupal.org because here we use Rules alpha5 (the latest tagged release). Locally and on Travis testing, where the latest -dev version of Rules is used, we see this failure.

jonathan1055’s picture

In manual testing, when attempting to first save a new ReactionRule having selected the event "After updating existing content that is scheduled for publishing"

The website encountered an unexpected error. Please try again later.
TypeError: Argument 2 passed to Drupal\rules\Engine\RulesComponent::addContextDefinition() must implement interface Drupal\rules\Context\ContextDefinitionInterface, array given, called in /rules/src/Engine/RulesComponent.php on line 175 in Drupal\rules\Engine\RulesComponent->addContextDefinition() (line 145 of /rules/src/Engine/RulesComponent.php).

Drupal\rules\Engine\RulesComponent->addContextDefinition('node', Array) (Line: 175)
Drupal\rules\Engine\RulesComponent->addContextDefinitionsForEvents(Array) (Line: 159)
Drupal\rules\Entity\ReactionRuleConfig->getComponent() (Line: 266)
Drupal\rules\Entity\ReactionRuleConfig->calculateDependencies() (Line: 319)
Drupal\Core\Config\Entity\ConfigEntityBase->preSave(Object) (Line: 499)
...
jonathan1055’s picture

Solved by changinf context: to context_definitions: in scheduler_rules_integration.rules.events.yml

scheduler_existing_node_is_scheduled_for_publishing_event:
  label: 'After updating existing content that is scheduled for publishing'
  category: 'Scheduler'
  context_definitions:
    node:
      type: 'entity:node'
      label: 'Scheduled Content Node'
      description: 'The node object representing the scheduled content'
jonathan1055’s picture

Status: Active » Needs review
StatusFileSize
new2.23 KB

This now works locally and on Travis tests, but will fail on drupal.org tests which use Rules Alpha5 not the latest -dev.

jonathan1055’s picture

StatusFileSize
new8.2 KB

Did not expect that particular failure in #5.

Patch #6 changes the context keys in RulesActions and Conditions, but not in the .rules.events.yml file.

jonathan1055’s picture

Issue summary: View changes
StatusFileSize
new10.44 KB

Patch #7 has the combined changes from #5 and #6.

jonathan1055’s picture

StatusFileSize
new10.86 KB

Now add composer.json change to load Rules and Typed Data -dev versions.

jonathan1055’s picture

Status: Needs review » Postponed
Related issues: +#3093191: Plan for Typed Data release 8.x-1.0-alpha4

Tests pass with -dev Rules and Typed Data. So the changes cannot be committed until a new Rules and Typed Data tagged release is made, as we do not want to use -dev versions in composer.json.

See #3093191: Plan for Typed Data release 8.x-1.0-alpha4

  • jonathan1055 committed 5d7bf68 on 8.x-1.x
    Issue #3101377 by jonathan1055: Interim fix - apply context_definitions...
jonathan1055’s picture

Status: Postponed » Needs review
StatusFileSize
new9.58 KB

Rules now has release 8.x-3.0-alpha6 (released 20 July) so the changes in #7 can be made. Also the temporary patching in .travis.yml needs to be removed.

  • jonathan1055 committed 670ea4a on 8.x-1.x
    Issue #3101377 by jonathan1055: Change context to  context_definitions...

  • jonathan1055 committed 0f67bee on 8.x-1.x
    Issue #3101377 by jonathan1055: Remove temporary Context Definitions...
jonathan1055’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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