• I just discovered this error on my multisite, the site runs fine. I disn’t notice any problem at all but i’d prefer not hafing this kind of errors on the site.

    When i go to
    Network Admin Dashboard
    Sites -> All Sites
    Click edit on any site of the network
    And then click users tab i get this warning on top of the page:
    “Warning: array_keys() expects parameter 1 to be array, boolean given in /home/nicoorg/public_html/wp-admin/includes/class-wp-users-list-table.php on line 307”

    This is the line 307:
    $editable_roles = array_keys( get_editable_roles() );

    And this is the content of the wp_2_user_riles table:
    http://pastebin.com/0MxtWCfM

    I suspect there’s something wrong on that table but i have no idea what it is.

    Thanks for any help.

Viewing 15 replies - 1 through 15 (of 16 total)
  • Have you tried:
    -deactivating all plugins to see if this resolves the problem. If this works, re-activate the plugins one by one until you find the problematic plugin(s).
    -switching to the default theme to rule out any theme-specific problems.

    Warning: array_keys() expects parameter 1 to be array, boolean given in /home/nicoorg/public_html/wp-admin/includes/class-wp-users-list-table.php on line 307

    Just so that you understand the error, you can read the Boolean page https://developer.wordpress.org/reference/functions/wp_validate_boolean/.

    Did you notice this only on WordPress 4.0, or have you noticed it on other WordPress versions (3.9.2, 3.9, 3.8, 3.7, etc.)?

    Thread Starter Doug

    (@nicoblog)

    I tried deactivating all plugins the error still shows up.
    I’m using twenty fourteen theme, so it’s pretty much default except for cosmetic css on the child.
    I learned that if i delete the admin i cannot add it anymore from the network panel, but if i go to the site specific dashboard there’s no errors and i can add the admin again.
    So the error only shows up on the network admin dashboard.
    I don’t know if it happened on previous versions since i don’t touch that part of the settings much.

    So the error is saying that this is a boolean? http://pastebin.com/0MxtWCfM

    Looks pretty much string to me =D

    Thread Starter Doug

    (@nicoblog)

    My issue is the exact same as this:
    https://wordpress.org/support/topic/user-role-problem-in-some-subdomain-sites?replies=4

    Except he had some good wp_#_user_roles table to copy, mines seem broken for all sites, something in here is wrong http://pastebin.com/0MxtWCfM
    but i don’t understand that code to debug it.

    Bumped (one month is not that old?). I have the same error (with a reference to line 307) and found it caused by the use of backupbuddy in WP4 to import a site to a multisite install.

    Thread Starter Doug

    (@nicoblog)

    Did you solve it?
    I never used backupbuddy but still have the error somehow.

    Francesco

    (@frankie_it_gen)

    same here (line307), after manually importing single sites to multi.
    also, user roles dropdown is empty.

    Feedback: The warning is caused by a missing or corrupt value for the wp_user_roles record/row in the wp_options table (or in the case of multisite the wp_xx_user_roles option name for the specific subsite). Probably caused by a rogue plugin. Short terms fix is to copy a working value from another site into the wp_user_roles field.

    Re Backupbuddy:
    It seems backupbuddy “forgets” to change the number part of the prefix in the option name when importing a site, e g if site with id 2 in the old setup is imported as site id 15 in the new setup, the option name is copied as wp_02_user_roles and not changed to wp_15_user_roles and therefor not recognized. This is a backupbuddy bug.

    this is the error Warning: array_keys() expects parameter 1 to be array, boolean given in /home/inditourcinfoway/public_html/wp-admin/includes/class-wp-upgrader.php on line 365
    The package could not be installed. The plugin contains no files.

    I solved this a couple weeks ago when I was having the same problem. Sometimes the issue comes when wp_#_user_roles has corrupted roles, and you need to track down some good ones to past into the database.

    However, the more common cause for this occurs when you change the database prefix in the database on an existing installation. I’m talking about when, for security reasons, we change the database table prefix from wp_ to something else. Many people do this during installation, some of us, like myself, did after installation using a script. I used the hardening tools from Sucuri. The scripts change the prefix of the table name only, they do not change the prefix of the row names inside the table.

    Chances are, your table name prefixes are something other than the default wp_, but on your various wp_#_user_role rows in the _options tables for the various sites, it is still wp_#_user_role. The hardening scripts that change this often don’t play well with multisite and rows don’t get changed, which causes that error report.

    To fix this, you need to go through the database and change the prefix on all the rows for wp_#_user_roles to newprefix_#_user_roles. The that row in the options table has to have the same prefix as all the table names in the database. I’ve been fixing mine manually, one at a time, but someone is more familiar with SQL commands may be able to write a command to handle it in one pass.

    Thread Starter Doug

    (@nicoblog)

    i went to look, i don’t even have any table with the words user_roles on it.
    :S

    Sorry, my description wasn’t quite clear.

    In phpMyAdmin, browse to your wp_#_options table for whatever subsite you need to fix (where # = the site id number). user_roles isn’t a table. It is in a row somewhere in that table, it will be identified in the option_name row.

    Once you are viewing the wp_#_options table, click Search near the top of the screen. You should have for database rows displayed: option_id, option_name, option_value and autoload. In the option_name row, use the select box to change the search parameter to LIKE%…% and in the search field type user_roles.

    This will return a short list and one of the rows will be wp_#_user_roles. Click edit for that row.

    You will then need to change the option name from wp_#_user_roles to match whatever your primary prefix is for your entire WP Database. For example, if your database table names are ieytr_options, then you need to change this option name to ieytr_#_user_roles. This prefix for this option name needs to match the prefix for the tables across your database.

    Thread Starter Doug

    (@nicoblog)

    Hi.
    I have 4 sites on this multisite.
    wp_
    wp_2
    wp_3
    wp_6

    2,3,6 have it named correctly:
    wp_2_user_roles
    wp_3_user_roles
    wp_6_user_roles
    The main site doesn’t have that row.

    The error shows on all 4 sites. Weird.

    The main site isn’t supposed to have it, it has one called wp_user_roles.

    If those prefixes all match up, then there is a chance the content in the option_value field is messed up. Unfotunately, I can’t help you there because you’ll need to get some good content for from somewhere.

    I would try creating a new site on the network and see if the error shows up on that one. If it doesn’t, then copy the content of option_value from it to the others.

    Thread Starter Doug

    (@nicoblog)

    Hey, there’s a huge block of text inside of it, i recognized words from old plugins i don’t have anymore, so probably it’s trash a plugin left behind after removing it.

    If i create a new site on the network is it safe to copy the content of the value to all the other sites? Are they supposed to be the same for all sites? Wouldn’t it mess up something? Hehe i’m scared 😛

    Thanks for the help btw!

    Just copy the existing stuff into a text file so you have it as a backup in case everything goes stupid.

    Theoretically, they should be the same for all the sites, unless you have some special functionlity needs due to plugins you are running on one site and not another. If all the sites are basically the same, then you should be alright. I’m sure there is alot stuff in there from older plugins and such. It is for that reason, that I cannot offer a copy-paste from my own (I’ve got alot of weird things going different plugins on my network).

    All else fails, spin up a new WP multisite install, set up a few subsites on it then go into the database and find out what a clean block looks in the option_value table.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Warning: array_keys() expects parameter 1 to be array’ is closed to new replies.