Skip to content

Condition plugins are sometimes being double-negated #1325

Closed
@qadan

Description

@qadan

Looking through the various plugins in \Drupal\islandora\Plugin\Condition - occasionally, $this->isNegated() is being referenced somewhere during the evaluate() process to feed a ternary returning either TRUE or FALSE, thereby handling the negation as part of the evaluation.

The problem is, Drupal core runs isNegated() after calling the condition plugin's evaluate() to accomplish the same thing in an identical ternary, so what ends up happening is if you decide to negate an affected condition, Islandora will negate the condition, and then Drupal will go ahead and un-negate it for you immediately afterwards, making it impossible to negate some filters.

This isn't consistently applied across all conditions, so some are unaffected (e.g., ContentEntityType and FileUsesFilesystem).

STR:

To check an affected filter:

  • Create a context
  • Add a condition that checks for Node has term
  • Add the term Collection
  • Check the "Negate the condition" box
  • Add a reaction of some kind; for simple testing purposes, I simply added one that changes the theme from Carapace to something else
  • Navigate to a collection, as well as a Repository Item that isn't a collection
  • Note that the reaction is fulfilled in both cases

Expected behaviour:

Checking off the "Negate the condition" box for a context condition should invert the conditions whereby that context is met.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions