Change WordPress user roles and capabilities › Forums › Bug Reports › Getting E_ERROR
- This topic has 2 replies, 2 voices, and was last updated 5 years ago by Vladimir.
-
AuthorPosts
-
15/11/2019 at 20:45 #6112[email protected]Participant
Hello, I am getting an error on from my wordpress page (see below): I have done some searching online but cannot find a solution. Can you please help me with this?
T page where the error was caught (https://nerdlevels.com/wp-admin/admin-ajax.php
When seeking help with this issue, you may be asked for some of the following information:
WordPress version 5.3
Current theme: BuddyBoss Child (version 1.0.0)
Current plugin: User Role Editor Pro (version 4.52)
PHP version 7.3.11Error Details
=============
An error of type E_ERROR was caused in line 457 of the file /home/u#########/domains/nerdlevels.com/public_html/wp-content/plugins/user-role-editor-pro/includes/classes/user-role-editor.php. Error message: Uncaught Error: Cannot unset string offsets in /home/u########/domains/nerdlevels.com/public_html/wp-content/plugins/user-role-editor-pro/includes/classes/user-role-editor.php:457
Stack trace:
#0 /home/u#########/domains/nerdlevels.com/public_html/wp-includes/class-wp-hook.php(290): User_Role_Editor->exclude_from_plugins_list(‘bp_core_unset_b…’)
#1 /home/u811831556/domains/nerdlevels.com/public_html/wp-includes/plugin.php(206): WP_Hook->apply_filters(‘bp_core_unset_b…’, Array)
#2 /home/u########/domains/nerdlevels.com/public_html/wp-content/plugins/buddyboss-platform/bp-loader.php(149): apply_filters(‘all_plugins’, ‘bp_core_unset_b…’, -1)
#3 /home/u########/domains/nerdlevels.com/public_html/wp-includes/class-wp-hook.php(288): bp_core_set_bbpress_buddypress_active(Array, ‘active_plugins’)
#4 /home/u########/domains/nerdlevels.com/public_html/wp-includes/plugin.php(206): WP_Hook->apply_filters(Array, Array)
#5 /home/u########/domains/nerdlevels.com/public_html/wp-includes/option.php(152): apply_filt16/11/2019 at 05:25 #6113VladimirKeymasterHi,
Thanks for this information.
User Role Editor (URE) hides itself from not administrator users who have access to the “Plugins” page. URE uses ‘all_plugins’ WordPress filter to exclude itself from the installed plugins list.
Look at this filter official definition:This filter should take parameter of type array, not the string, as BuddyBoss sends, according to the line #2 from the stack trace:
#2 /wp-content/plugins/buddyboss-platform/bp-loader.php(149): apply_filters(‘all_plugins’, ‘bp_core_unset_b…’, -1);
URE tries unset array element for its own record in line 461:
459 // exclude URE from plugins list
460 $key = basename(URE_PLUGIN_DIR) . ‘/’ . URE_PLUGIN_FILE;
461 unset($plugins[$key]);Look at the screenshot below. I took it from PHP debugger at my test site.
$plugins parameter contains array of installed plugins as it should by WordPress design and documentation.But at your site $plugins modified by BuddyBoss executed ‘all_plugins’ filter earlier with lower priority (-1 comparing to default 10), contains not array with plugins list, but the string ‘bp_core_unset_b…’. Finally, I see this as a reason of PHP error, raised inside URE code.
I’m ready to investigate the issue further if you can provide me BuddyBoss plugin (plus a theme if required) for testing. Share it with support [at-sign] role-editor.com via Google Drive or similar.
19/11/2019 at 03:13 #6123VladimirKeymasterThanks for the provided access to the source code. There were similar error reports at wordpress.org support forum. I duplicate the answer here:
The reason of a problem is a line of code at the BuddyBoss platform plugin. Open wp-content/plugins/buddyboss-platform/bp-load.php file and look at the line #149:
apply_filters( 'all_plugins', 'bp_core_unset_bbpress_buddypress_active_all_plugins', - 1 );
It incorrectly calls `apply_filters’ for WordPress core ‘all_plugins’ filter. Why do I think so? Be cause of it sends to it not array with plugins list, as WordPress itself does at includes/class-wp-plugins-list-table.php:91:
$all_plugins = apply_filters( 'all_plugins', get_plugins() );
where functionget_plugins()
returns “array Key is the plugin file path and the value is an array of the plugin data”.But it sends own function ‘bp_core_unset_bbpress_buddypress_active_all_plugins’ and priority value: -1. These parameters are valid for
add_filter()
function.
I suppose this is just a typo.More,
bp_core_unset_bbpress_buddypress_active_all_plugins()
function which belongs to BuddyBoss Platform plugin accept a single $plugins parameter and returns it unchanged.So quick fix is replace line #149 with this valid version:
add_filter( 'all_plugins', 'bp_core_unset_bbpress_buddypress_active_all_plugins', - 1 );
-
AuthorPosts
- You must be logged in to reply to this topic.