Support » Plugin: Admin Toolbar Menus » PHP notices with WP_DEBUG on

  • Resolved protohominid

    (@protohominid)


    Hey – Love the plugin, thanks! I was wondering if you could make some minor updates to eliminate PHP notices I’m getting in my local environment with WP_DEBUG on. I’m getting a lot of these messages in wp-admin:

    Notice: Trying to get property of non-object in /…/wp-content/plugins/admin-toolbar-menus/admin-toolbar-menus.php on line 115

    Thanks again.

    https://wordpress.org/plugins/admin-toolbar-menus/

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Benbodhi

    (@benbodhi)

    Hi there,
    Thanks for your support!
    I haven’t seen these notices, I’ll take a look first chance I get.
    Thanks for letting me know.

    BTW, here are the details from the notices (from the “Query Monitor” plugin):

    Notice: Trying to get property of non-object
    […]/plugins/admin-toolbar-menus/admin-toolbar-menus.php:115

    Call Stack
    bodhi_atm_add_admin_menus()
    do_action_ref_array(‘admin_bar_menu’)
    wp_admin_bar_render()
    do_action(‘in_admin_header’)

    Plugin Author Benbodhi

    (@benbodhi)

    Thanks for your update here!

    I haven’t had a chance to take a look yet unfortunately 🙁
    Hopefully will be able to spend some time on it very soon.
    Thanks for your patience!

    I get the same error notices. I would appreciate if you could look into it as soon as possible. Thanks!

    Plugin Author Benbodhi

    (@benbodhi)

    Hi there,

    I can’t seem to reproduce these notices…
    I have WP_DEBUG on and installed the Query Monitor plugin, still can’t see them anywhere.

    Can you please provide more info to help me reproduce so I can sort it out? Such as what menu locations are in use while you see these notices and do they always appear, or just under some certain circumstances?

    I have an idea of why it would happen, but cannot test if I can’t see the notices my self.

    Thanks
    Ben

    Thanks for looking into this, Benbodhi. I have WP_DEBUG set to false but I’m using the Query Monitor plugin, so this is where I’m seeing the errors.

    Just a reminder that I’m using the Plus version of the plugin, which you created for me when I requested additional menu locations… It’s working out very well for me, BTW!

    From the front end of my site, I get 1 PHP error related to this plugin. I’ve checked pages, posts, and archives, and the error is always the same. Here are the details:

    PHP Error:
    Notice — Trying to get property of non-object
    
    Count:
    1
    
    Location:
    wp-includes/nav-menu.php:665
    
    Call Stack:
    wp_setup_nav_menu_item()
    array_map()
    wp_get_nav_menu_items()
    bodhi_atm_add_admin_menus()
    do_action_ref_array('admin_bar_menu')
    wp_admin_bar_render()
    do_action('wp_footer')
    wp_footer()
    load_template('~/wp-content/themes/MY_THEME/footer.php')
    locate_template()
    get_footer()
    
    Component:
    Plugin — admin-toolbar-menus-plus

    I’m unable to reproduce the error from the back end of the site. I tried from the Dashboard, the post listing screen, the post edit screen, a taxonomy listing screen, a taxonomy edit screen, and the menu settings screen.

    I didn’t seen anything in the php error logs.

    As for the menu locations, all of the ones provided by the plugin (My Account, Site Name, Main, Main 2, Main 4) are in use when the error occurs, except for Main 3, which I only use on the back end.

    I hope these details will help you! Cheers!

    Plugin Author Benbodhi

    (@benbodhi)

    Oh awesome, thanks, I’ll check now…
    I hadn’t checked the front end (whoops).

    Oops — I edited my message while you were typing…

    Thanks!

    Plugin Author Benbodhi

    (@benbodhi)

    I still can’t get them to show up… then I thought, maybe it only happens on live sites, not local dev.
    But nope… ran both the standard and the plus version of the plugin with other plugins, no other plugins, tried on frontend pages, posts, archives, admin pages… still nothing 🙁

    I have no idea why I cannot reproduce the issue.

    I will try to work on it anyway, but it’s hard to tell if what I have done will work without being able to test it. baffled.

    I just tried disabling all other plugins (except for query monitor) and I still get the PHP notices. Let me know if you need me to try any modifications on my end to test.

    Does this stack overflow answer apply?
    http://stackoverflow.com/a/19849765/355788

    Plugin Author Benbodhi

    (@benbodhi)

    That definitely points to very similar issues… I have a few resources I’ve found that explain it quite well… I have been tweaking the code but the menus disappear.
    I am also working on re-writing the whole section that this is in, so I might do that first and make sure to address this issue while re-writing it all.

    If I still cannot get the notices to show at that point, I might have to get your help for testing, thank you for the offer 🙂

    I’ve thought of a few more details which may be helpful…

    First, I forgot that Main 3 is hidden from the front end with a css class, so it does actually render in the page source. Sorry about that!

    Second, I’m wondering if the issue might have anything to do with how many menu items are in the menu? Mine are all pretty close to the 50 limit — about 40 or so each. Just a thought…

    Alright… I have tried with huge amounts of menus items in place, not yet with CSS hiding one from front… but that shouldn’t affect PHP.
    I will keep trying different things and see if I can reproduce first chance I get.

    Thanks!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘PHP notices with WP_DEBUG on’ is closed to new replies.