I have a relatively clean Drupal install which I started building from scratch yesterday. I've created a block (containing only plain text) and used context_og to create a Context to show the block when I'm in a Group. I've used the "OG - group type context" condition, and set it for the single Group type I currently have - "Client".

Now, when I browse to a "Client" Group, I get a white screen of death. Enabling PHP error messsages gives me the following:

Fatal error: Cannot use object of type OgGroup as array in /home/mark/public_html/seedling.d7.lan/htdocs/sites/all/modules/context_og/plugins/context_og_condition_group_node.inc on line 42

Something else which may be of note - when I enabled context_og, I started getting the following the following warning when editing any Context, repeated 5 times:

Notice: Trying to get property of non-object in context_og_condition_group_node->condition_values() (line 14 of /home/mark/public_html/seedling.d7.lan/htdocs/sites/all/modules/context_og/plugins/context_og_condition_group_node.inc).

For further info on my install, I have attached the results of a phpinfo() file in plain text. The relevant module versions I'm using are all the recommended versions, downloaded with drush (eg drush dl context context_og og etc.):

  • context 7.x-3.0-beta2
  • context_og 7.x-1.0
  • og 7.x-1.3
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

realnerd’s picture

Hi Mark,

I encountered the exact same problem, it was solved for me by installing the latest dev-version (7.x-1.x-dev)

zengenuity’s picture

I can confirm that 7.x-1.0 crashes as described. Even after I fixed those specific issues, there were still more problems because 1.0 has code that mixes up node NIDs and group GIDs, trying to do stuff like node_load($gid). It's strange because the latest 1.x-dev is a few month older than 7.x-1.0. Looks like some code from the 6.x series got moved into here somehow.

Regardless, 7.x-1.x-dev from 2011-Nov-22 works for me.

dman’s picture

I just got this on the stable. (new site)
I tried shifting to the -dev and while it didn't break any more, the conditions I was hoping to trigger

OG - group type context
* In any group

don't seem to fire.
I also tried the group-node-type option

I'm testing with 'debug' as a reaction.

EDIT: MY BAD. Looks like it was the 1.x/2.x change that got me there. RTFM :-}

dman’s picture

Not all my bad.
Same error exists in 7.x-2.x dev.

I had to fix it with the following patch.
THIS PATCH IS FOR 7.x-2.x-dev, but I won't switch the version here, as it's still current on the stable 7.x-1.0

jgraham’s picture

Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)

Hi all can you post more details with the versions and issues you are experiencing?

Please note that context_og 2.x is for og 2.x, and context_og 1.x is for og 1.x.

If you are using the corresponding versions please follow up with more details here on the issues you are having.

mrfelton’s picture

I got this problem with 1.0. Using 7.x-dev resolves.

jramby’s picture

same as #6

snufkin’s picture

Status: Postponed (maintainer needs more info) » Active

Its really easy to reproduce, just create a context, even without any conditions and reactions. Create a group content type: poof error.

The issue is that $group in execute($group) is not an array, but an object.

I tested with context og 7.x-1.0 with og 7.x-1.3

The patch above does resolve this issue however.

veades’s picture

The problem appears to be generated in the execute($group) functions in the two condition classes.

$group being passed in is an object so the first if statement with $group['group_type'] =='node' is throwing the error.

I'm debugging my copy. Changing to $group->entity_type =='node' seems to be fixing it.
Then can get node by:
$node = node_load($group->etid);

dman’s picture

veades’s picture

Thanks. Good to know. Sorry I'm new at this. Not sure how to use the patches yet, my bad.

dman’s picture

@veades
It's no biggie, as soon as anyone works up the courage to actually *look* at a raw patch file (especially a nice simple example like this one) and doesn't go "Z0MG, scary code!" you'll see it's actually pretty damn obvious to see what's going on with the naked eye.
Just look fot the '+' and '-' signs.

pav’s picture

Same error on attempting to create a new context accompanied by:

Notice: Trying to get property of non-object in context_og_reaction_set_group_context->options_form() (line 16 of mysite/sites/all/modules/context_og/plugins/context_og_reaction_set_group_context.inc).

Tried patch in #4 with no result.

Current 7.x-1.x-dev works for me (but not 7.x-2.x-dev).

jgraham’s picture

From my experience and testing I cannot get this bug to trigger with og 2.x and context_og 2.x.

1. The current 1.0 release is bad, it should be 2.0 (if anything) as such I have unpublished it. I messed up the packaging on this and I am terribly sorry for the confusion and problems this has caused.
2. If you are using og 1.x. I can't get the dev release to show up. Maybe because I'm not the primary maintainer, and as such the nightly's for the dev release are not building. http://drupal.org/node/1348756 I will try to get a new 1.1 release out so that you can download this directly and/or get the 1.x-dev release rebuilding properly.

jgraham’s picture

For those of you on the 1.x branch can you please test with the 1.x-dev version. Right now the best way to do this is via git.

The following will get the latest 1.x-dev from git for you. Just cd into your modules directory first and remove the existing context_og.
git clone --recursive --branch 7.x-1.x http://git.drupal.org/project/context_og.git

jgraham’s picture

The tarball/zip builds of the dev branch should build soon so you should be able to grab those if you wait instead of going the git route.

If you could please postback to indicate if the latest dev builds work for you that would be great.

snufkin’s picture

Status: Active » Reviewed & tested by the community
FileSize
640 bytes

I can confirm that using context_og 7.x-2.x-dev throws the error: Cannot use object of type OgGroup as array, but I am using og-7.x-1.3, so I guess thats expected.

While context_og-7.x-1.x-dev throws the following notices:

Notice: Undefined variable: acontext in context_og_condition_group_type->execute() (line 57 of /Users/balu/Sites/pixelpark/sites/all/modules/context_og/plugins/context_og_condition_group_type.inc).
Notice: Trying to get property of non-object in context_condition->condition_met() (line 141 of /Users/balu/Sites/pixelpark/sites/all/modules/context/plugins/context_condition.inc).
Notice: Trying to get property of non-object in context_condition_met() (line 375 of /Users/balu/Sites/pixelpark/sites/all/modules/context/context.module).
Notice: Trying to get property of non-object in context_condition_met() (line 387 of /Users/balu/Sites/pixelpark/sites/all/modules/context/context.module).

This is because on line 57 the variable is misspelled ($acontext instead of $context). Once I fixed that it works fine, so attaching the patch that changes this, so marking it as RTBC.

play4quarters’s picture

Thanks much to both of you! That cleared up the errors I was seeing as well. Very appreciated.

jgraham’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the catch snufkin. This has been committed and a 1.1 release has been made.

Thanks for everyone's patience as we sorted out the issues here.

The 2.x branch will remain without a release until og has a stable release. The API in og is still changing and may break stuff.

Status: Fixed » Closed (fixed)

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

jayaram’s picture

I got this error after updating the entity module. Does this require any fix ?

kclarkson’s picture

I too am receiving this error when trying to create a new context.

I updated the entity module to fix another issue.

kclarkson’s picture

Status: Closed (fixed) » Active

set to active

St.Ego’s picture

Organic groups 7.x-2.0-rc2
Entity API 7.x-1.0-rc3+11-dev
Context OG 7.x-2.1
Notice: Trying to get property of non-object in context_og_condition_group_node->execute() (line 42)

Line 42 is looking for $group->entity_type (ie: $group as an object), but it is getting an array. Interestingly, line 54, later in the same function, it is looking for $group['gid'], which it would be able to find, if it didn't error out first...

jpwester’s picture

I'm seeing the same thing.

Organic groups: 7.x-2.0-rc3
Context: 7.x-3.0-beta6
Context OG: 7.x-2.1
Entity API: 7.x-1.0

kclarkson’s picture

Version: 7.x-1.0 » 7.x-2.1

Just wondering if anybody else is still receiving this error. I have cleared my cache, updated entity api and am still receiving this error.

Here are my errors:
Notice: Trying to get property of non-object in context_og_condition_group_node->condition_values() (line 14 of /sites/all/modules/contrib/context_og/plugins/context_og_condition_group_node.inc).
Notice: Trying to get property of non-object in context_og_reaction_set_group_context->options_form() (line 16 of/sites/all/modules/contrib/context_og/plugins/context_og_reaction_set_group_context.inc).