OK, I’ve dug into things a bit and I think this both is and is not a bug.
Yes, the code looks strange. If we’re on multisite, $user_count is set to an integer. In a standalone installation, it’s set to an array.
The $query variable is then constructed from a set of variables, one being $user_count['total_users']. Logically, this should fail for Multisite, and that’s exactly what you’re seeing.
However, and this is a big however, I can’t reproduce the warning you’re seeing. Even setting WP_DEBUG and forcing E_ALL for error reporting, $user_count['total_users'] returns the integer value and not a warning or error.
I’ve tried this on two different Apache systems and an Nginx system. I can’t get that error back out of the system, though I can see exactly where it would come up. I’ll post a ticket on Trac anyway, but I’m not seeing this as a wide-reaching issue (See #20966).
A short-term fix for you would be to turn off or lower your PHP warning settings.
I found out… that if I run in a PHP version < 5.4
$expected_array_got_string = 'somestring';
echo $expected_array_got_string['some_key'];
that it returns “s”
However starting from PHP version 5.4. it will throw: Warning: Illegal string offset ‘some_key’
🙂
I think that’s the reason for the low amount of users seeing it…
(see also example 2 here: http://php.net/manual/en/function.empty.php )
SO… to see the warning… simply install PHP version 5.4 or later 🙂
Thanks for your infomation, cogmios.
I know this topic is resolved. But I have the same PHP warning, so, I want to say “Thank you!”. I also want to add the next information.
You wrote:
However starting from PHP version 5.4. it will throw: Warning: Illegal string offset ‘some_key’
However, PHP version 5.4 also returns “s” by my test.
When I test the next script, a PHP version < 5.4 returns “0”, but PHP version 5.4 returns “1”.
$expected_array_got_string = 'somestring';
echo empty($expected_array_got_string['some_key']);
Yeah… it seems we are part of the 0.2% grin
In case you haven’t been following along, this has been fixed in Core, so it shouldn’t be a problem with the next version:
https://core.trac.wordpress.org/changeset/21105
The patch was included in 3.4.1. After you upgrade, let me know for sure that it resolved the issue. But you should be golden 🙂
18:31 : illegal offset
18:31 : You can update to WordPress 3.4.1 automatically or download the package and install it manually: click
18:32 : message gone
Today, I updated my site. The message has gone, too.
Thanks.