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.
Comment | File | Size | Author |
---|---|---|---|
#3 | field_access.patch | 979 bytes | catch |
Comments
Comment #1
yched CreditAttribution: yched commentedNo patch :-)
The "loop on module_implements('field_access')" approach sounds fine.
Comment #2
yched CreditAttribution: yched commentedBTW, 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.
Comment #3
catchWhoops, here's a patch. Added the change to the loop.
Comment #4
yched CreditAttribution: yched commentedCool.
Comment #5
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.