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.
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.
Comment | File | Size | Author |
---|---|---|---|
#5 | og-context-node-add-1795400.patch | 674 bytes | gpk |
Comments
Comment #1
Grayside CreditAttribution: Grayside commentedCould you see if it works with reset() instead of current()?
Comment #2
gpk CreditAttribution: gpk commentedYes seems to work fine.
Also I think the line just above
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
Comment #3
Grayside CreditAttribution: Grayside commentedYou 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?
Comment #4
gpk CreditAttribution: gpk commented@3: yes I do mean that. I would just add
is_array($_REQUEST['gids'])
to theelseif
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 withcurrent()
.Comment #5
gpk CreditAttribution: gpk commentedHere's a patch including #4 also.
Comment #6
Grayside CreditAttribution: Grayside commentedhttp://drupalcode.org/project/og.git/commit/f2ffdb1
Sorry, I forgot to give you --author credit in Git before pushing.
Comment #7
gpk CreditAttribution: gpk commentedLooks OK to me? Anyway, more to the point, thanks for fixing this.
Comment #9
gpk CreditAttribution: gpk commentedNB 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.
Comment #10
gpk CreditAttribution: gpk commentedFor 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...!