If a term condition has been added using a taxonomy term that was subsequently deleted, trying to edit the form with that condition produces the following error:

InvalidArgumentException: The #default_value property has to be an entity object or an array of entity objects.

Any chance of simply ignoring the default value if it isn't an actual term entity?

CommentFileSizeAuthor
#4 deleted-terms-fix_3068565_3.patch1.36 KBdanielveza

Comments

jastraat created an issue. See original summary.

danielveza’s picture

Yes good call. I had this ticket line up to work on #3056194: [meta] Investigate fixes for deleting Vocabs

But a totally sane call is to also check if the term(s) implement TermInterface on load. Lets try that.

danielveza’s picture

Status: Active » Needs work

Here is a patch that checks if term exists otherwise you get a WSOD on D9

Todo:

Consider a hook_term_delete to delete terms on blocks.
Add tests.

danielveza’s picture

StatusFileSize
new1.36 KB
dieuwe’s picture

Status: Needs work » Closed (outdated)

I'm closing all old issues for the 8.x-1.x-dev branch. If this issue is still relevant, please update and re-open it for the 2.0.x-dev branch.

dieuwe’s picture

In this case, I have already committed #3325547: PHP fatal error when trying to edit a condition that references a deleted term which seems like it solves the same problem in a different way (the patch from here still applies on 2.0.x). Happy to revisit approach if needed.