Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
designcontext CreditAttribution: designcontext commentedSo, 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.
Comment #2
RobW CreditAttribution: RobW commentedIs the number of times field_collection_item_access runs connected to the number of field collections or field collection items on a page?
Comment #3
designcontext CreditAttribution: designcontext commented4 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
Comment #3.0
designcontext CreditAttribution: designcontext commentedadditional information
Comment #4
jmuzz CreditAttribution: jmuzz commentedStrange 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)).
Comment #5
Andy Tawse CreditAttribution: Andy Tawse commentedI'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).
Comment #6
jmuzz CreditAttribution: jmuzz commented