I have a page manager page at 'taxonomy/term/%term/admin'. This page pulls over a VBO view and nothing else. I get an error when visiting this page from the taxonomy.module file.

warning: Illegal offset type in isset or empty in /var/www/modules/taxonomy/taxonomy.module on line 1090, 1091 and 1094.

I've narrowed this down to the data that is being passed into the first parameter in taxonomy_get_term($tid, $reset = FALSE). Somehow this function is being passed a ctools_context object for the $tid parameter. Here is the object below. I used my good friend print_r() to find the data.

This is how print_r() prints out objects.

    ctools_context Object
    (
        [type] => term
        [data] => stdClass Object
            (
                [tid] => 24
                [vid] => 1
                [name] => Coca-Cola "STUFF"
                [description] => lots of misc. collectibles...one of a kind items!
     
                [weight] => 0
            )
     
        [title] => Coca-Cola "STUFF"
        [page_title] =>
        [identifier] => Taxonomy term: ID
        [argument] => 24
        [keyword] => term
        [original_argument] => 24
        [restrictions] => Array
            (
            )
     
        [empty] =>
        [plugin] => term
        [description] => lots of misc. collectibles...one of a kind items!
     
        [id] => argument_term_1
    )

Here is the object.

<?php
$tid->type = 'term';
$tid->data = new stdClass();
$tid->data->tid = 24;
$tid->data->vid = 1;
$tid->data->name = 'Coca-Cola "STUFF"';
$tid->data->description = 'lots of misc. collectibles...one of a kind items!';
$tid->data->weight = 0;
$tid->title = 'Coca-Cola "STUFF"';
$tid->page_title = '';
$tid->identifier = 'Taxonomy term: ID';
$tid->argument = 24;
$tid->keyword = 'term';
$tid->original_argument = 24;
$tid->restrictions = array();
$tid->empty = '';
$tid->plugin = 'term';
$tid->description = 'lots of misc. collectibles...one of a kind items!';
$tid->id = 'argument_term_1';
?>

I'm not sure what function is responsible for passing in this object as the $tid... Hopefully someone with some more experience can lend a hand. Thanks for the help in advance

Comments

merlinofchaos’s picture

Perhaps a debug_backtrace() in taxonomy_get_term would help, to see where that's being called from.

Steven Brown’s picture

Thank you merlin :) Didn't know that function existed.

So I've never used this function before and it's output is an array. However, I'm not sure when reading the output but I don't see the object described above which concerns me... Maybe I'm just not reading correctly.

Array
(
    [0] => Array
        (
            [file] => /var/www/sites/all/modules/contrib/ctools/plugins/arguments/term.inc
            [line] => 40
            [function] => taxonomy_get_term
            [args] => Array
                (
                    [0] => 45
                )

        )

    [1] => Array
        (
            [file] => /var/www/sites/all/modules/contrib/ctools/includes/context.inc
            [line] => 756
            [function] => ctools_term_context
            [args] => Array
                (
                    [0] => 45
                    [1] => Array
                        (
                            [input_form] => tid
                            [vids] => Array
                                (
                                    [3] => 0
                                    [1] => 0
                                )

                            [breadcrumb] => 1
                        )

                    [2] => 
                )

        )

    [2] => Array
        (
            [file] => /var/www/sites/all/modules/contrib/ctools/page_manager/plugins/tasks/page.inc
            [line] => 557
            [function] => ctools_context_get_context_from_argument
            [args] => Array
                (
                    [0] => Array
                        (
                            [id] => 1
                            [identifier] => Taxonomy term: ID
                            [name] => term
                            [settings] => Array
                                (
                                    [input_form] => tid
                                    [vids] => Array
                                        (
                                            [3] => 0
                                            [1] => 0
                                        )

                                    [breadcrumb] => 1
                                )

                            [keyword] => term
                        )

                    [1] => 45
                )

        )

    [3] => Array
        (
            [file] => /var/www/sites/all/modules/contrib/ctools/page_manager/page_manager.module
            [line] => 865
            [function] => _pm_arg_load
            [args] => Array
                (
                    [0] => 45
                    [1] => ca_vocab_catalog_vocab_product_admin
                    [2] => 2
                )

        )

    [4] => Array
        (
            [function] => pm_arg_load
            [args] => Array
                (
                    [0] => 45
                    [1] => ca_vocab_catalog_vocab_product_admin
                    [2] => 2
                    [3] => Array
                        (
                            [0] => taxonomy
                            [1] => term
                            [2] => 45
                            [3] => admin
                        )

                )

        )

    [5] => Array
        (
            [file] => /var/www/includes/menu.inc
            [line] => 409
            [function] => call_user_func_array
            [args] => Array
                (
                    [0] => pm_arg_load
                    [1] => Array
                        (
                            [0] => 45
                            [1] => ca_vocab_catalog_vocab_product_admin
                            [2] => 2
                            [3] => Array
                                (
                                    [0] => taxonomy
                                    [1] => term
                                    [2] => 45
                                    [3] => admin
                                )

                        )

                )

        )

    [6] => Array
        (
            [file] => /var/www/includes/menu.inc
            [line] => 568
            [function] => _menu_load_objects
            [args] => Array
                (
                    [0] => Array
                        (
                            [path] => taxonomy/term/%/admin
                            [load_functions] => a:1:{i:2;a:1:{s:11:"pm_arg_load";a:3:{i:0;s:36:"ca_vocab_catalog_vocab_product_admin";i:1;s:6:"%index";i:2;s:4:"%map";}}}
                            [to_arg_functions] => 
                            [access_callback] => ctools_access_menu
                            [access_arguments] => a:2:{i:0;a:4:{s:7:"plugins";a:2:{i:0;a:3:{s:4:"name";s:24:"worx_plugins_role_access";s:8:"settings";a:1:{s:9:"worx_role";s:27:"vocab catalog administrator";}s:3:"not";b:0;}i:1;a:3:{s:4:"name";s:3:"php";s:8:"settings";a:2:{s:11:"description";s:9:"If user 1";s:3:"php";s:74:"global $user;
if ($user->uid == 1) {
return TRUE;
}
else {
return FALSE;
}";}s:3:"not";b:0;}}s:5:"logic";s:2:"or";s:4:"type";s:4:"none";s:8:"settings";N;}i:1;i:2;}
                            [page_callback] => page_manager_page_execute
                            [page_arguments] => a:2:{i:0;s:36:"ca_vocab_catalog_vocab_product_admin";i:1;i:2;}
                            [fit] => 13
                            [number_parts] => 4
                            [tab_parent] => taxonomy/term/%
                            [tab_root] => taxonomy/term/%
                            [title] => Administration
                            [title_callback] => t
                            [title_arguments] => 
                            [type] => 128
                            [block_callback] => 
                            [description] => 
                            [position] => 
                            [weight] => 3
                            [file] => sites/all/modules/contrib/ctools/page_manager/plugins/tasks/page.inc
                        )

                    [1] => Array
                        (
                            [0] => taxonomy
                            [1] => term
                            [2] => 45
                            [3] => admin
                        )

                )

        )

    [7] => Array
        (
            [file] => /var/www/includes/menu.inc
            [line] => 318
            [function] => _menu_translate
            [args] => Array
                (
                    [0] => Array
                        (
                            [path] => taxonomy/term/%/admin
                            [load_functions] => a:1:{i:2;a:1:{s:11:"pm_arg_load";a:3:{i:0;s:36:"ca_vocab_catalog_vocab_product_admin";i:1;s:6:"%index";i:2;s:4:"%map";}}}
                            [to_arg_functions] => 
                            [access_callback] => ctools_access_menu
                            [access_arguments] => a:2:{i:0;a:4:{s:7:"plugins";a:2:{i:0;a:3:{s:4:"name";s:24:"worx_plugins_role_access";s:8:"settings";a:1:{s:9:"worx_role";s:27:"vocab catalog administrator";}s:3:"not";b:0;}i:1;a:3:{s:4:"name";s:3:"php";s:8:"settings";a:2:{s:11:"description";s:9:"If user 1";s:3:"php";s:74:"global $user;
if ($user->uid == 1) {
return TRUE;
}
else {
return FALSE;
}";}s:3:"not";b:0;}}s:5:"logic";s:2:"or";s:4:"type";s:4:"none";s:8:"settings";N;}i:1;i:2;}
                            [page_callback] => page_manager_page_execute
                            [page_arguments] => a:2:{i:0;s:36:"ca_vocab_catalog_vocab_product_admin";i:1;i:2;}
                            [fit] => 13
                            [number_parts] => 4
                            [tab_parent] => taxonomy/term/%
                            [tab_root] => taxonomy/term/%
                            [title] => Administration
                            [title_callback] => t
                            [title_arguments] => 
                            [type] => 128
                            [block_callback] => 
                            [description] => 
                            [position] => 
                            [weight] => 3
                            [file] => sites/all/modules/contrib/ctools/page_manager/plugins/tasks/page.inc
                        )

                    [1] => Array
                        (
                            [0] => taxonomy
                            [1] => term
                            [2] => 45
                            [3] => admin
                        )

                )

        )

    [8] => Array
        (
            [file] => /var/www/includes/menu.inc
            [line] => 345
            [function] => menu_get_item
            [args] => Array
                (
                    [0] => 
                )

        )

    [9] => Array
        (
            [file] => /var/www/index.php
            [line] => 17
            [function] => menu_execute_active_handler
            [args] => Array
                (
                )

        )

)

If anyone reads through this ummm karma++ :) Thanks for the help.

merlinofchaos’s picture

Will that trace looks fine to me. I think, though, that maybe what you need to do is put it in an if() and check that the argument taxonomy_get_term() gets is actually wrong before doing the backtrace.

Steven Brown’s picture

Bingo... :) Found the file. Not sure what to do with it though.

Array
(
    [0] => Array
        (
            [file] => /var/www/sites/all/modules/contrib/page_title/modules/taxonomy.page_title.inc
            [line] => 41
            [function] => taxonomy_get_term
            [args] => Array
                (
                    [0] => ctools_context Object
                        (
                            [type] => term
                            [data] => stdClass Object
                                (
                                    [tid] => 24
                                    [vid] => 1
                                    [name] => Coca-Cola "STUFF" 
                                    [description] => lots of misc. collectibles...one of a kind items!

                                    [weight] => 0
                                )

                            [title] => Coca-Cola "STUFF" 
                            [page_title] => 
                            [identifier] => Taxonomy term: ID
                            [argument] => 24
                            [keyword] => term
                            [original_argument] => 24
                            [restrictions] => Array
                                (
                                )

                            [empty] => 
                            [plugin] => term
                            [description] => lots of misc. collectibles...one of a kind items!

                            [id] => argument_term_1
                        )

                )

        )

)
Steven Brown’s picture

Just looked closer... not sure how the page_title module would be messing up things or sending over a ctools_context object.

Steven Brown’s picture

So it is the page_title module... and not sure how it would be causing this. Also, I believe I should move this to the page_title module. However, Merlin I will let you determine that just in case there's something I'm over looking.

merlinofchaos’s picture

It's causing this because Page Manager is getting a context object from the menu loader, but page title is expecting a taxonomy tid and not verifying that. Since the path is not taxonomy/term/% page title is probably confused that the % isn't conforming to what taxonomy/term/% has. It's a fundamental difference between how page manager works and how Drupal works natively because page manager is very dependent upon context.

Steven Brown’s picture

I just reviewed the code that calls taxonomy_get_term(). What is being passed to the $tid is $menu_item['map'][2]. The map 2 just happens to be the ctools_context object.

Array
(
    [path] => taxonomy/term/%/admin
    [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:3:{s:4:"name";s:24:"worx_plugins_role_access";s:8:"settings";a:1:{s:9:"worx_role";s:27:"vocab catalog administrator";}s:3:"not";b:0;}i:1;a:3:{s:4:"name";s:3:"php";s:8:"settings";a:2:{s:11:"description";s:9:"If user 1";s:3:"php";s:74:"global $user;
if ($user->uid == 1) {
return TRUE;
}
else {
return FALSE;
}";}s:3:"not";b:0;}}s:5:"logic";s:2:"or";s:4:"type";s:4:"none";s:8:"settings";N;}i:1;i:2;}
    [page_callback] => page_manager_page_execute
    [page_arguments] => Array
        (
            [0] => ca_vocab_catalog_vocab_product_admin
            [1] => ctools_context Object
                (
                    [type] => term
                    [data] => stdClass Object
                        (
                            [tid] => 24
                            [vid] => 1
                            [name] => Coca-Cola "STUFF" 
                            [description] => lots of misc. collectibles...one of a kind items!

                            [weight] => 0
                        )

                    [title] => Coca-Cola "STUFF" 
                    [page_title] => 
                    [identifier] => Taxonomy term: ID
                    [argument] => 24
                    [keyword] => term
                    [original_argument] => 24
                    [restrictions] => Array
                        (
                        )

                    [empty] => 
                    [plugin] => term
                    [description] => lots of misc. collectibles...one of a kind items!

                    [id] => argument_term_1
                )

        )

    [fit] => 13
    [number_parts] => 4
    [tab_parent] => taxonomy/term/%
    [tab_root] => taxonomy/term/%
    [title] => Administration
    [title_callback] => t
    [title_arguments] => 
    [type] => 128
    [block_callback] => 
    [description] => 
    [position] => 
    [weight] => 3
    [file] => sites/all/modules/contrib/ctools/page_manager/plugins/tasks/page.inc
    [href] => taxonomy/term/24/admin
    [options] => Array
        (
        )

    [access] => 1
    [localized_options] => Array
        (
        )

    [map] => Array
        (
            [0] => taxonomy
            [1] => term
            [2] => ctools_context Object
                (
                    [type] => term
                    [data] => stdClass Object
                        (
                            [tid] => 24
                            [vid] => 1
                            [name] => Coca-Cola "STUFF" 
                            [description] => lots of misc. collectibles...one of a kind items!

                            [weight] => 0
                        )

                    [title] => Coca-Cola "STUFF" 
                    [page_title] => 
                    [identifier] => Taxonomy term: ID
                    [argument] => 24
                    [keyword] => term
                    [original_argument] => 24
                    [restrictions] => Array
                        (
                        )

                    [empty] => 
                    [plugin] => term
                    [description] => lots of misc. collectibles...one of a kind items!

                    [id] => argument_term_1
                )

            [3] => admin
        )

)

So my question is, should there be a patch or is this just an issue because this is how Drupal vs Page Manager works and I need to live with it?

Steven Brown’s picture

Status: Active » Closed (works as designed)

Cross referencing issues #1811526: Illegal offset type in isset or empty taxonomy.module lines 1090, 1091, 1094.

I have proposed a simple solution on the page_title's issue queue. Not sure what to change the status to but to me this is closed(Works as designed).

Thanks for all the help Merlin