function og_vocab_is_group_admin_context() {
  if (strpos($_GET['q'], 'group/') === 0 && ($item = menu_get_item()) && !empty($item['map'][2])) {
    return array('group_type' => $item['map'][1], 'gid' => $item['map'][2]);
  }

So $item['map'][2] might be an object, not a number, and when it is, bam, fatal error when it alters the vocab query cause the db_placehodler is a object instead of a number.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hefox’s picture

Array
(
    [path] => group/node/%/admin/ical
    [load_functions] => Array
        (
            [2] => pm_arg_load
        )

    [to_arg_functions] => 
    [access_callback] => ctools_access_menu
    [access_arguments] => a:2:{i:0;a:4:{s:7:"plugins";a:2:{i:0;a:4:{s:4:"name";s:9:"node_type";s:8:"settings";a:1:{s:4:"type";a:1:{s:8:"oa_space";s:8:"oa_space";}}s:7:"context";s:25:"argument_entity_id:node_1";s:3:"not";b:0;}i:1;a:4:{s:4:"name";s:7:"og_perm";s:8:"settings";a:1:{s:4:"perm";s:16:"administer group";}s:7:"context";a:2:{i:0;s:14:"logged-in-user";i:1;s:25:"argument_entity_id:node_1";}s:3:"not";b:0;}}s:5:"logic";s:3:"and";s:4:"type";s:4:"none";s:8:"settings";N;}i:1;i:2;}
    [page_callback] => page_manager_page_execute
    [page_arguments] => Array
        (
            [0] => oa_ical_feeds
            [1] => ctools_context Object
                (
                    [type] => Array
                        (
                            [0] => entity:node
                            [1] => entity
                            [2] => node
                        )

                    [data] => stdClass Object
                        (
                            [vid] => 6
                            [uid] => 1
                            [title] => sfasdf
                            [log] => 
                            [status] => 1

A sample the menu item.

hefox’s picture

Status: Active » Needs review
FileSize
568 bytes
amitaibu’s picture

Thanks. Maybe we should check arg(2) is a numeric value?

hefox’s picture

Sounds like a good idea, added validation for both args.

amitaibu’s picture

Thanks, but I think it's a little hard to read. Maybe you can break it to a few lines/ IFs and maybe add a comment?

JKingsnorth’s picture

Status: Needs review » Needs work

Marking as needs work from amitaibu's comment.

anvmn’s picture

Here's a patch that checks if $item['map'][2] is an object, and if so, sets $gid to it's id value...

amitaibu’s picture

Status: Needs work » Needs review

Setting correct status