0

We are using Business Rules to execute a view (users) that returns a list of email addresses. It works fine when rule is triggered by admin, but does not work when triggered by other users. In debugging it I found the following:

  1. as both users the view returns the correct result rows, ie. $view->result is identical for both users.
  2. as admin the view object contains a list of the fields which business_rules uses, ie. $fields = $view->field is an array keyed on 'mail';
  3. as any other user $view->field is empty UNLESS I turn on administer users permissions for that user's role!

I am thinking that in views a permission to view the mail field is being checked when the 'fields' are populated into the view object. But, oddly enough that permission does not effect the view result as mentioned in #1.

Any thoughts on how to debug this further?

3
  • In the advanced settings of the view under query options disable SQL rewriting to prevent access checks. Does it work now? – leymannx Mar 26 at 18:57
  • There is a workaround for this. Create a new fiels which is duplicate of email field and make queries to that field. Refer below answer for more details drupal.stackexchange.com/a/272771 – miststudent2011 Mar 28 at 5:31
  • 1
    Thank-you for the referenced post @miststudent2011, I did not find that one when looking for solutions. I considered creating a 'mirror' field for it as a plan 'B' if I could not find a solution. – JoelB Mar 29 at 13:51
2

If anyone else sees this it is because view does a checkAccess before adding the field during preExecute. Since it is the mail field there is no other way to allow access to that field unless you give administer users. But, there is a patch coming out that introduces a mail field access permission.

https://drupal.org/project/drupal/issues/2799049

With patch and permission set everything works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.