Got this error when editing a term containing an ER field pointing to a taxonomy field filtered by a view:
Notice : Undefined index: target_bundles dans taxonomy_permissions_entity_field_access() (ligne 54 de /var/www/html/drupal8/modules/contrib/taxonomy_permissions/taxonomy_permissions.module)

There is also another warning,... don't know if this is linked
Warning : Invalid argument supplied for foreach() in taxonomy_permissions_entity_field_access() (ligne 58 de /var/www/html/drupal8/modules/contrib/taxonomy_permissions/taxonomy_permissions.module)

Comments

DuneBL created an issue. See original summary.

dunebl’s picture

Priority: Minor » Major

Just to add: this is clearly coming from the ER view wich is filtering the term to encode in the field.
Note also that the widget of the ER taxo field doesn't appear if the reference method is an ER View... this is why I turn the priority into major (No widget=can't encode the value of the field)
If I set the reference method to "default" the error disappear.

dunebl’s picture

Title: Undefined index: target_bundles dans taxonomy_permissions_entity_field_access() » Problem when using an ER view as target_bundles
dunebl’s picture

Here is a patch thar return AccessResult::neutral() when a view is used as a reference method.

salvis’s picture

Status: Active » Needs review

Thank you for your patch, DuneBL!

Is TP working for you otherwise?

dunebl’s picture

@salvis: yes, it looks like it is working...

salvis’s picture

Thanks, DuneBL!

I can't test this at this point. Any reviewers out there?

john_a’s picture

@salvis @DuneBL,

We have just faced the same issue, with content types with term ER fields. These fields mysteriously disappeared form the node edit page, with the same error log messages.

I can confirm that this patch resolves the issue. It makes sense to use neutral in this case.

CORRECTION:

I think we may have found an issue with this patch. This removes the errors and warnings, but all roles can now create new terms, even if the role does not have that permission granted.

salvis’s picture

Status: Needs review » Needs work

Thank you, john_a!

salvis’s picture

@DuneBL: Have you checked #8 on your site? Any idea for a fix?

dunebl’s picture

regarding #8, as explained in the comments of the patch, I don't see a way to check the access. This access check must be done in the view which is used to reference the terms.
Of course, if someone have a better idea, it could be great.

salvis’s picture

Thank you for your reply, @DuneBL.

I'm not sure what to do about this now...