I noticed that the group context block had disappeared when viewing node/add/page?gids[]=2026 or whatever.

Traced the problem to line 620 of og.module:

$gid = intval(current($_REQUEST['gids']));

http://drupalcode.org/project/og.git/blame/1d59d880bf510cda8a35c0ced507d...

It seems that in PHP 5.3, current($_REQUEST['gids']) doesn't give the same result as in 5.2 - this returns nothing basically. If I revert back to PHP 5.2, all is well and the block reappears.

CommentFileSizeAuthor
#5 og-context-node-add-1795400.patch674 bytesgpk
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Grayside’s picture

Could you see if it works with reset() instead of current()?

gpk’s picture

Yes seems to work fine.

Also I think the line just above

elseif (strpos($path, 'node/add') === 0 && !empty($_REQUEST['gids'])) {

should include an additional test to make sure that $_REQUEST['gids'] is an array. At the moment you can generate a PHP warning by cooking up a URL that omits the [] such as:

node/add/story?gids[]=1

Grayside’s picture

You mean node/add/story?gids=1?
That would either be checking that it's an array, or something forgiving that converts it to an array if not already.

Someone want to roll a patch?

gpk’s picture

@3: yes I do mean that. I would just add is_array($_REQUEST['gids']) to the elseif clause; any URLs omitting the [] are malformed and should not be "baby-sat" but on the other hand shouldn't generate a PHP warning.

And as I said at #2, reset() does fix the original problem with current().

gpk’s picture

Status: Active » Needs review
FileSize
674 bytes

Here's a patch including #4 also.

Grayside’s picture

Status: Needs review » Fixed

http://drupalcode.org/project/og.git/commit/f2ffdb1

Sorry, I forgot to give you --author credit in Git before pushing.

gpk’s picture

Looks OK to me? Anyway, more to the point, thanks for fixing this.

Status: Fixed » Closed (fixed)

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

gpk’s picture

NB with some older versions of PHP 5.3 e.g. 5.3.18 you may not hit this problem but it does rear its head in e.g. 5.3.23.

gpk’s picture

For info ... this problem does not arise in PHP 5.3.29 either, so maybe it was just a "feature" of certain PHP versions between (but not including) 5.3.18 and 5.3.29 that current($_REQUEST['gids']) would return an empty result...!