#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Location
    Ithaca
    Posts
    68
    Rep Power
    2

    PHP 5.4.0 Illegal String offset warning


    Well I upgraded to PHP 5.4 and my vbulletin forum is showing this warning.
    Warning: Illegal string offset 'do' in [path]/includes/functions_online.php on line 458
    I was wondering though, is there a way to suppress illegal string offset warning in PHP 5.4? Just curious.
  2. #2
  3. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,756
    Rep Power
    9397
    As far as I can tell, vBulletin doesn't support PHP 5.4.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Location
    Ithaca
    Posts
    68
    Rep Power
    2
    Originally Posted by requinix
    As far as I can tell, vBulletin doesn't support PHP 5.4.
    Yeah I know of that, I have been trying to fix the incompatibilities. I was able to resolve the ampersand symbol error, the forum actually works pretty well right now. I do not get any fatal errors, just some annoying warnings like this one.
  6. #4
  7. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,756
    Rep Power
    9397
    If you're willing to fix code then try the form
    PHP Code:
    $string[is_string($string) ? intval($offset) : $offset
    (because I have to assume that under some conditions $string is actually an array)
    If $offset is a hardcoded string then you can do away with the intval() and simply
    PHP Code:
    $string[is_string($string) ? "do"
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Location
    Ithaca
    Posts
    68
    Rep Power
    2
    This is where the warning message is generated, so yeah the variable is an array. The $userinfo['values']['do'] is what causing the problem. Interestingly, the warning message is only generated when an online user is viewing PM box.

    PHP Code:
            case 'pm':
                
    $userinfo['action'] = $vbphrase['private_messaging'];
                if (
    $vbulletin->userinfo['permissions']['wolpermissions'] & $vbulletin->bf_ugp_wolpermissions['canwhosonlinefull'])
                {
                    if (
    $seeuserid)
                    {
                        
    $userinfo['where'] = '<a href="member.php?' $vbulletin->session->vars['sessionurl'] . "u=$seeuserid\">$wol_user[$seeuserid]</a>";
                    }
                    if (
    $userinfo['values']['do'] == 'newpm' OR $userinfo['values']['do'] == 'insertpm' OR $userinfo['values']['do'] == 'newmessage')
                    {
                        
    $userinfo['action'] = $vbphrase['creating_private_message'];
                    }
                    else if (
    $userinfo['values']['do'] == 'editfolders' OR $userinfo['action']['do'] == 'updatefolders')
                    {
                        
    $userinfo['action'] = $vbphrase['modifying_private_message_folders'];
                    }
                    else if (
    $userinfo['values']['do'] == 'trackpm' OR $userinfo['values']['do'] == 'deletepmreceipt')
                    {
                        
    $userinfo['action'] = $vbphrase['tracking_private_messages'];
                    }
                    else if (
    $userinfo['values']['do'] == 'showpm')
                    {
                        
    $userinfo['action'] = $vbphrase['viewing_private_message'];
                    }
                    else if (
    $userinfo['values']['do'] == 'downloadpm')
                    {
                        
    $userinfo['action'] = $vbphrase['downloading_private_messages'];
                    }

                }
                break; 
  10. #6
  11. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,756
    Rep Power
    9397
    The code clearly expects $userinfo['values'] to be an array but apparently isn't in that case. So what is its value?
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Location
    Ithaca
    Posts
    68
    Rep Power
    2
    I am not quite sure, but it seems to me that it is null. Weird though...
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    1
    Rep Power
    0
    I think it's a bug in that code and must read $userinfo['values']['do'] == 'updatefolders' instead of $userinfo['action']['do'] == 'updatefolders'

IMN logo majestic logo threadwatch logo seochat tools logo