field_access() uses is_null() to see if $account is set, where isset() would do fine - see #530950: user_access() should use isset() instead of is_null() which is exactly the same thing.

Attached is a very simple patch to change that.

However while in there I noticed this hunk:

  $field_access = module_invoke_all('field_access', $op, $field, $obj_type, $object, $account);
  foreach ($field_access as $value) {
    if ($value === FALSE) {
      return FALSE;
    }
  }
  return TRUE;
}

Seems like we could save some cycles by doing $field_access_modules = module_implements('field_access'), then looping through with $function and checking the return each time - that way if one returns FALSE, there'd be no call to the subsequent modules. I'm not sure though if there's any practical chance of having more than one field access module installed, so left it at the is_null() change for now.

CommentFileSizeAuthor
#3 field_access.patch979 bytescatch
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched’s picture

No patch :-)

The "loop on module_implements('field_access')" approach sounds fine.

yched’s picture

Status: Reviewed & tested by the community » Needs review

BTW, I think there's a chance to have several field modules enabled. The contrib replacement for core profile will probably implement access rules of its own to mimic the existing core options.

catch’s picture

FileSize
979 bytes

Whoops, here's a patch. Added the change to the loop.

yched’s picture

Status: Needs review » Reviewed & tested by the community

Cool.

Dries’s picture

Status: Needs review » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)
Issue tags: -Performance

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