Closed (fixed)
Project:
Organic Groups Entityform Integration
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Oct 2015 at 15:28 UTC
Updated:
9 Nov 2015 at 21:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
zekvyrin commentedSo, I've made some changes in this function and I think it's now working in all cases.
The problem is that $all_groups isn't always an array.
When cardinality is set to 1, $all_groups is an object (it is the group). When it is set to 2 or higher (or unlimited) it is an array of objects.
This is entity_metadata_wrapper's behaviour.
So what I did is:
1) check if $all_groups an array (cardinality >1) and then (if it is) check if the array is empty.
If it is an array and it is empty, it means that we have a cardinality >1 and 0 values in the field.
If it is an array and isn't empty do what we were doing before.
2) check if $all_groups is an object (cardinality is 1)
if it is, it means that we the cardinality is 1 and the field has value so we add the group properly in the array.
3) Finally, if the variable is empty (both is_array and is_object returns false), then the cardinality is 1, but the field is empty (no group), so we aren't doing anything. ( no code needed for this one)
Comment #3
zekvyrin commentedSorry, wrong patch.. please ignore my previous patches
Comment #4
b_manComment #6
zengenuity commentedThanks @Zekvyrin. I was able to replicate the issue, and your patch fixes it. Committed.