• Resolved cogmios

    (@cogmios)


    see https://www.ads-software.com/support/topic/illegal-string-offset-total-users?replies=5#post-2889483

    Direct after upgrading to 3.4 I noticed Illegal string offset ‘total_users’ in update.php on line 75.

    On line 55 it requests

    $user_count = get_user_count( );

    I echo this value and it is an integer (2) so not an array

    on line 73 however it requests

    $user_count['total_users'],

    (so an array….. ) this is where it fails on my WP multisite install.

    So im thinking what could be wrong since my get_user_count() does not return an array but just “2” (so an integer)

    (but obviously this should be an array since it has been an array for always)

Viewing 8 replies - 16 through 23 (of 23 total)
  • 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.

    Thread Starter cogmios

    (@cogmios)

    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: https://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']);
    Thread Starter cogmios

    (@cogmios)

    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.www.ads-software.com/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 ??

    Thread Starter cogmios

    (@cogmios)

    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.

Viewing 8 replies - 16 through 23 (of 23 total)
  • The topic ‘Illegal string offset 'total_users'’ is closed to new replies.