Support » Plugin: Revisionary » Conflict with User Switching

  • There seems to be a conflict with the User Switching plugin. When a user with the Revisor role tries to edit a page, this kind of error occurs:

    [12-Sep-2017 11:57:21 UTC] PHP Fatal error: Uncaught TypeError: Argument 4 passed to user_switching::filter_user_has_cap() must be an instance of WP_User, none given, called in /wordpress-4.8.1/wp-includes/class-wp-hook.php on line 298 and defined in /wp-content/plugins/user-switching/user-switching.php:816 Stack trace: #0 /wordpress-4.8.1/wp-includes/class-wp-hook.php(298): user_switching->filter_user_has_cap(Array, Array, Array)
    #1 /wordpress-4.8.1/wp-includes/plugin.php(203): WP_Hook->apply_filters(Array, Array)
    #2 /wp-content/plugins/revisionary/lib/agapetry_wp_core_lib.php(152): apply_filters('user_has_cap', Array, Array, Array)
    #3 /wp-content/plugins/revisionary/admin/filters-admin-ui-item_rvy.php(30): agp_user_can(Array, '47', '', Array)
    #4 /wp-content/plugins/revisionary/admin/filters-admin-ui-item_rvy.php(13): RevisionaryAdminFiltersItemUI->add_js()
    #5 /wp-content/plugins/revisionary/admin/admin_rvy.php(133): RevisionaryAdminFiltersItemUI->RevisionaryAdminFiltersItemUI()
    #6 /wordpress-4.8.1/wp-inclu in /wp-content/plugins/user-switching/user-switching.php on line 816

    Comments:

    • user-switching.php:816 doesn’t seem to have a relevant function call in it
    • The user-switching.php filter_user_has_cap() hooked function accepts 3 args
      /revisionary/lib/agapetry_wp_core_lib.php:152 passes 3 args
    • The WP filter (https://codex.wordpress.org/Plugin_API/Filter_Reference/user_has_cap) seems to accept 3 args
    • So, can’t really see where this 4th arg is coming into play and spoiling things!

    I imagine the issue, like many conflicts, might fall foul of each plugin developer assuming it’s the other’s problem 😉 Also, since User Switching isn’t used regularly, I’ve applied the easy solution of deactivating it, to activate only when needed – so it’s not critical. But I thought I’d notify you, will cross-post to User Switching.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi Steve,
    Ive come across this conflict too. Im not sure how to actually submit a patch for this just yet but if you wanted to know how to fix it:
    In file: revisionary/lib/agapetry_wp_core_lib.php on line 152

    Change:
    $capabilities = apply_filters('user_has_cap', $user->allcaps, $reqd_caps, $_args);

    To:
    $capabilities = apply_filters('user_has_cap', $user->allcaps, $reqd_caps, $_args, $user);

    This will correctly pass through all the arguments which the user_has_cap filter expects and stop the issue with User Switching.

    That’s great, many thanks. Does anyone have any idea if this plugin is active – no updates in 2 years?

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.