• After upgrading to version 1.7.3 of this plugin I started seeing the following errors in my log file:

    PHP Notice: Undefined offset: 0 in /home/…/wp-includes/capabilities.php on line 181

    I believe that this caused by passing only a single argument to current_user_can. Note in the documentation that ommiting this second $object_id argument will cause just this error. A scan confirmed that the plugin code was not using the $object_id argument.

    Eventually I got a stack trace on this which pointed to Admin Menu Editor. I confirmed by deactivating the plugin. The errors disappeared. I then downgraded to version 1.7.2. No issues there as well. The problem seems to be only in 1.7.3.

    Thanks, Max

Viewing 1 replies (of 1 total)
  • Plugin Author Janis Elsts

    (@whiteshadow)

    Thank you for the report. However, it’s probably not as simple as a missing argument. Here’s why:

    The $object_id argument is optional. It only needs to be used when calling current_user_can() on a meta capability like “edit_post”, in which case it specifies the post ID that the user is trying to edit. Normally, it makes no sense to use meta capabilities in the admin menu because the WordPress API for creating admin menus only accepts a single capability argument and has no way to set an $object_id. As a result, Admin Menu Editor usually doesn’t deal with meta capabilities, so it doesn’t need to use the $object_id argument.

    That said, of course there’s always a risk that there could be a plugin conflict, a bug, or a configuration issue that causes AME to unintentionally use a meta capability.

    Since you have a stack trace, can you please tell me the plugin file name and line number where this notice was triggered? Also, some PHP versions will log function arguments along with the stack trace, so do you know what capability the plugin was checking at the time?

    • This reply was modified 7 years, 3 months ago by Janis Elsts.
Viewing 1 replies (of 1 total)
  • The topic ‘Plugin throwing “undefined offset”’ is closed to new replies.