If for some reason a condition plugin is no longer registering, and that condition has been used, an error is returned anywhere the condition is viewed/edited. I think it would be best to replicate how this is handled in views, where a Broken handler will essentially take place of the missing plugin. In our case, this would be a BrokenCondition which would automatically return 'false' when evaluated in javascript.

We will need to decide where would be best to to place the logic for swapping in BrokenCondition in the place of the missing plugin. I think potentially Drupal\smart_content\Condition\ConditionManager::createInstance() could have a check to see if the plugin exists, and if it doesn't, then it would return the fallback.

This would reduce the need for checking if the definition exists every time you want to create an instance. The only risk would be if you are calling 'createInstance' with the expectation to get the exact Condition you called, because you are calling condition specific behavior, however this is something we are generally trying to avoid.

Open to other ideas, but this is where my heads at currently.

Comments

michaellander created an issue. See original summary.

gantal’s picture

Issue tags: +dcco2019

Tagging for DrupalCamp Colorado's upcoming contrib day.

  • michaellander committed 8a34133 on 8.x-1.x
    Issue #3026950 by michaellander: Create BrokenCondition as fallback to...
michaellander’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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