On my site I have a field collection in a profile. I have a strange behaviour: every user can add fc-items, but some users can edit and delete them, others not. Access denied. I see no rule: a user with role a can edit, another with role a not.
Does someone have an idea where I should look for the error?
Thank you very much!
Katharina

Comments

designcontext’s picture

So, we checked it and I can give a little bit more information:
in field_collection.module is a function field_collection_item_access. This function checks entity access and field access. Only with both values true a user can change or delete his items.

We printes out the results of this function in the profile. The function runs multiple times for one profile. For a user with no access the results are:
1. + 2. run: hostEntityType empty, field access: true, entity access: false
3. + 4. run: hostEntityType profile2, fa. true, ea true
For a user with access the function runs 6 times and everytime the both accesses are true and the type is profile2.

We found no differences between the stored data in the database.

Please, has someone an idea about this? Our site is ready - only this little thing doesn't work.

RobW’s picture

Is the number of times field_collection_item_access runs connected to the number of field collections or field collection items on a page?

designcontext’s picture

4 runs with one item and with every field-collection-item two runs more. With three field-collection-items the results are:
item->hostEntityType: field_access: 1 entity_access:
item->hostEntityType: field_access: 1 entity_access:
item->hostEntityType: field_access: 1 entity_access:
item->hostEntityType: field_access: 1 entity_access:
item->hostEntityType: field_access: 1 entity_access:
item->hostEntityType: field_access: 1 entity_access:
item->hostEntityType: profile2 field_access: 1 entity_access: 1
item->hostEntityType: profile2 field_access: 1 entity_access: 1

designcontext’s picture

Issue summary: View changes

additional information

jmuzz’s picture

Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)

Strange those field collection items don't seem to have a host type. Can you look more closely at them and see if they are missing any other information (var_export or krumo/dpm) ? Maybe you can run some backtraces to find out if there is a difference in how it is called between when the hostEntityType exists or not (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)).

Andy Tawse’s picture

I'm seeing this too and it seems to be related to this issue https://www.drupal.org/node/2407435

In field_collection_item_access(), if you check that $entity_access is strictly not false it seems to work (haven't done much testing outside my situation).

I had this problem with an entity reference field and they fixed their problem in a similar way - https://www.drupal.org/node/1909436#comment-7615877 (see that comment in particular).

jmuzz’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)