For example, if you have a rule with a condition based on page paths which do not correspond to a node content type, the Content type condition is still being saved and is checked in the rule entity isActive method: as this plugin has missing context on non-node pages the condition will fail and prevent the rule from activating.

The solution is to not save/add a plugin when it's form has no values. In the above example only the 'Pages' plugin would have anything in the form, so this is the only plugin which would be saved and participate in the condition check in isActive.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pstewart created an issue. See original summary.

pstewart’s picture

The attached patch updates the conditions form handling to match the equivalent functionality in block for block visibility. With this patch applied, empty conditions are not saved and correct behaviour occurs on rules targeting non node pages.

Siegrist’s picture

Status: Active » Reviewed & tested by the community

#2 works for me!

joelpittet’s picture

@pstewart In core it looks like conditions forms don't show at all if the context doesn't exist, is this patch supposed to hide them similarly?

BarisW’s picture

Thanks, the patch works as advertised. I'll commit it.

  • BarisW committed d662ce6 on 8.x-1.x authored by pstewart
    Issue #3027844 by pstewart, Siegrist, joelpittet, BarisW: Unused...
BarisW’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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