Hi all,

After enabling the stream context block for an organic groups page, I am getting the following:

Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of C:\wamp\www\learnsys\includes\entity.inc).
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 354 of C:\wamp\www\learnsys\includes\entity.inc).

I notice that this is only when the actual comment box is displayed, if I turn that off, no errors. Anyone else getting this or does anyone have an idea of how to begin solving this?

Thanks,

kevin

Comments

aleix’s picture

I've found the same and in my case is solved patching og.module as: http://drupal.org/node/1368930 says.
If not... get your hands dirty and do some backtraces.

icecreamyou’s picture

The error probably happens when Statuses calls og_is_member() in statuses.context.inc lines 234, 243, and 248 if og_get_group_ids() returns an empty array. The solution should just be to check if we get an empty array before calling og_is_member() in those cases.

rabisg’s picture

came up with a patch based on IceCreamYou's suggestion. It doesn't really change much. But still attaching the patch as it is a good idea to check whether array is empty or not before passing it in a function.

icecreamyou’s picture

Status: Active » Needs work

Use spaces instead of tabs, and all non-ternary conditions should be wrapped in curly braces. Other than that this looks fine

rabisg’s picture

icecreamyou’s picture

+++ b/includes/utility/statuses.contexts.inc
@@ -230,22 +230,36 @@ class statuses_og_context extends statuses_node_context {
+  $group_ids = og_get_group_ids('node', array($recipient->nid));
+   if(!empty($group_ids)) {
+    return parent::access_add($recipient, $sender) && og_is_member(current($group_ids), 'user', $sender);
+   }
+  return FALSE;

Wrong spacing. Each block level should be indented exactly 2 spaces from its parent block

+++ b/includes/utility/statuses.contexts.inc
@@ -230,22 +230,36 @@ class statuses_og_context extends statuses_node_context {
+    if(!empty($group_ids)) {

There needs to be a space between language constructs and parenthesis, i.e. if (condition) not if(condition). This problem occurs several times

+++ b/includes/utility/statuses.contexts.inc
@@ -230,22 +230,36 @@ class statuses_og_context extends statuses_node_context {
+	  return parent::access_delete($status, $account) || in_array(OG_ADMINISTRATOR_ROLE, og_get_user_roles(current($group_ids), $account->uid, FALSE));

still tab here

+++ b/includes/utility/statuses.contexts.inc
@@ -230,22 +230,36 @@ class statuses_og_context extends statuses_node_context {
+		return parent::access_view($status, $account) &&

still tabs here

+++ b/includes/utility/statuses.contexts.inc
@@ -230,22 +230,36 @@ class statuses_og_context extends statuses_node_context {
+    if(!empty($group_ids)) {
     return parent::access_stream($recipient, $account) &&
-      (og_is_member(current(og_get_group_ids('node', array($recipient->nid))), 'user', $account->uid) || empty($recipient->og_private));
+      (og_is_member(current($group_ids), 'user', $account->uid) || empty($recipient->og_private));
+    }

the body of a block should be indented

rabisg’s picture

Sorry for being a little careless last time. Hope this does it.

icecreamyou’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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