Announcement

Collapse
No announcement yet.

Fatal error: Unsupported operand types in usercp and PM

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
    amn.com.sa
    New Member

  • amn.com.sa
    replied
    Originally posted by fraggle View Post
    Got the same problem yesterday. Length of string containing native symbols in UTF-8 doesn't equal to its length in original encoding. Users having such PM folders or subfolders names can't use usercp. So you need to fix it.
    Wrote little script which convert all wrong serialized arrays and update pmfolders and subfolders fields at usertextfield table if it needed.

    How to use:

    1. Make a copy of your usertextfield table
    2. Change $old_encoding in the script to your original encoding
    3. Put the script to the forum server
    4. Run it
    5. If it needed, change encoding to UTF-8 in your browser
    6. Examine the output. Red lines are the strings to be changed. 's' value in original and new strings differs.
    7. Press 'Repair!'
    8. If it is OK, there will be green status 'OK' in each line
    9. Press 'Refresh' link at the bottom. There shouldn't be any red lines anymore.

    fyi, there are some other places where you should update serialized arrays. For example, I had several own created profile fields in profilefield table which didn't work too. Fixed it manually.
    do you think this can fix password table also.
    after I change encoding to UTF-8 some users have trouble login.

    Leave a comment:

  • Mr.Tampax
    Member

  • Mr.Tampax
    replied
    Originally posted by fraggle View Post
    Got the same problem yesterday. Length of string containing native symbols in UTF-8 doesn't equal to its length in original encoding. Users having such PM folders or subfolders names can't use usercp. So you need to fix it.
    Wrote little script which convert all wrong serialized arrays and update pmfolders and subfolders fields at usertextfield table if it needed.

    How to use:

    1. Make a copy of your usertextfield table
    2. Change $old_encoding in the script to your original encoding
    3. Put the script to the forum server
    4. Run it
    5. If it needed, change encoding to UTF-8 in your browser
    6. Examine the output. Red lines are the strings to be changed. 's' value in original and new strings differs.
    7. Press 'Repair!'
    8. If it is OK, there will be green status 'OK' in each line
    9. Press 'Refresh' link at the bottom. There shouldn't be any red lines anymore.

    fyi, there are some other places where you should update serialized arrays. For example, I had several own created profile fields in profilefield table which didn't work too. Fixed it manually.
    Thank you very much, bro!
    Спасибо брат за отличное решение!

    Leave a comment:

  • Adem GENÇ
    Senior Member

  • Adem GENÇ
    replied
    Originally posted by fraggle View Post
    Got the same problem yesterday. Length of string containing native symbols in UTF-8 doesn't equal to its length in original encoding. Users having such PM folders or subfolders names can't use usercp. So you need to fix it.
    Wrote little script which convert all wrong serialized arrays and update pmfolders and subfolders fields at usertextfield table if it needed.

    How to use:

    1. Make a copy of your usertextfield table
    2. Change $old_encoding in the script to your original encoding
    3. Put the script to the forum server
    4. Run it
    5. If it needed, change encoding to UTF-8 in your browser
    6. Examine the output. Red lines are the strings to be changed. 's' value in original and new strings differs.
    7. Press 'Repair!'
    8. If it is OK, there will be green status 'OK' in each line
    9. Press 'Refresh' link at the bottom. There shouldn't be any red lines anymore.

    fyi, there are some other places where you should update serialized arrays. For example, I had several own created profile fields in profilefield table which didn't work too. Fixed it manually.
    Thank you very much

    Leave a comment:

  • fraggle
    New Member

  • fraggle
    replied
    Solution for User panel problem

    Got the same problem yesterday. Length of string containing native symbols in UTF-8 doesn't equal to its length in original encoding. Users having such PM folders or subfolders names can't use usercp. So you need to fix it.
    Wrote little script which convert all wrong serialized arrays and update pmfolders and subfolders fields at usertextfield table if it needed.

    How to use:

    1. Make a copy of your usertextfield table
    2. Change $old_encoding in the script to your original encoding
    3. Put the script to the forum server
    4. Run it
    5. If it needed, change encoding to UTF-8 in your browser
    6. Examine the output. Red lines are the strings to be changed. 's' value in original and new strings differs.
    7. Press 'Repair!'
    8. If it is OK, there will be green status 'OK' in each line
    9. Press 'Refresh' link at the bottom. There shouldn't be any red lines anymore.

    fyi, there are some other places where you should update serialized arrays. For example, I had several own created profile fields in profilefield table which didn't work too. Fixed it manually.
    Attached Files

    Leave a comment:

  • Emath
    Senior Member

  • Emath
    replied
    Originally posted by David Grove View Post
    You can have folders with the same name, so I would just do this:

    For every instance of
    Code:
    s:NUMBER:"TEXT";
    replace it with
    Code:
    s:14:"Renamed folder"
    Where 14 is the number of characters in the name you are going to use.

    So if you have a user with the following data:
    Code:
    a:2:{i:1;s:6:"[FONT=&quot]الوارد[/FONT]";i:2;s:6:"[FONT=&quot]الصادر[/FONT]";}
    Change it to:

    Code:
    a:2:{i:1;s:14:"Renamed folder";i:2;s:14:"Renamed folder";}
    Then the users should be able to rename their folders themselves.

    Be sure to back up your database before trying this, and/or try it on a test installation first.
    this worked for me. tested on vb3.8.6

    the table that the data is stored in is vb_usertextfield

    thanks all.

    Leave a comment:

  • Emath
    Senior Member

  • Emath
    replied
    anyone?

    Leave a comment:

  • Emath
    Senior Member

  • Emath
    replied
    yes, where we go in phpmyadmin to fix it?

    i really need help here ..

    thanks.

    Leave a comment:

  • the_webmaster
    Member

  • the_webmaster
    replied
    Originally posted by BBF View Post
    first of all, i am sorry for bumping this thread.
    i had the same problem that you described here and i found a better solution - so i want the share this solution with you

    let say that we have the line:
    PHP Code:
    a:1:{i:1;s:13:"הודעות חשובות";} 
    (these are hebrew characters).

    as you can see there are 13 characters.
    but the right s parameter is 25 and not 13.
    why? because in UTF-8 every non-english character is 2 byte long and no 1 byte.

    so we have to double this number (13*2 = 26) and subtract by 1 for each space.
    so the final line will be:
    PHP Code:
    a:1:{i:1;s:25:"הודעות חשובות";} 
    i hope you understand me, and sorry for my lame english

    edit:
    i forgot to say that i have vBulletin 4.0.5 and this solution tested in it.


    I have too many members they have this problem, so do I have to edit every one ?

    if so , where do I go in my phpmyadmin to fix that?

    Leave a comment:

  • Emath
    Senior Member

  • Emath
    replied
    i also have this error. though the script above not helping me.

    any ideas , someone ?

    Leave a comment:


  • BBF
    replied
    first of all, i am sorry for bumping this thread.
    i had the same problem that you described here and i found a better solution - so i want the share this solution with you

    let say that we have the line:
    PHP Code:
    a:1:{i:1;s:13:"הודעות חשובות";} 
    (these are hebrew characters).

    as you can see there are 13 characters.
    but the right s parameter is 25 and not 13.
    why? because in UTF-8 every non-english character is 2 byte long and no 1 byte.

    so we have to double this number (13*2 = 26) and subtract by 1 for each space.
    so the final line will be:
    PHP Code:
    a:1:{i:1;s:25:"הודעות חשובות";} 
    i hope you understand me, and sorry for my lame english

    edit:
    i forgot to say that i have vBulletin 4.0.5 and this solution tested in it.
    Last edited by BBF; Fri 27 Aug '10, 5:30am.

    Leave a comment:

  • the_webmaster
    Member

  • the_webmaster
    replied
    Originally posted by David Grove View Post

    PHP Code:
    // change this
    if (!empty($vbulletin->userinfo['pmfolders']))
    {
        
    $pmfolders $pmfolders unserialize($vbulletin->userinfo['pmfolders']);
    }

    // to this
    if (!empty($vbulletin->userinfo['pmfolders']))
    {
        
    $cachedpmfolders unserialize($vbulletin->userinfo['pmfolders']);
        if (
    is_array($cachedpmfolders) AND !empty($cachedpmfolders))
        {
            
    $pmfolders $pmfolders $cachedpmfolders;
        }
        unset(
    $cachedpmfolders);


    thanks alot

    I modified functions_user.php with this . and I can log into my pm's and all member that they have same problems


    I'm running vb.401 and now my encoding utf-8


    but do I have to stick to this all my vb.4.0.x I ment even after upgradeing to 4.0.2 and so what ever come ?

    Leave a comment:


  • Mansour
    replied
    Thanks very much sockwater for this information, it really help me to solve the problem. I think I will go with the replacment to a default data and the user update it if they want.
    Thanks man

    and many thanks to Jake Bunce for your support.

    Best Regards,

    Leave a comment:

  • David Grove
    Senior Member

  • David Grove
    replied
    Originally posted by Mansour View Post
    3- I update the filed with other content (the above one that work) : a:2:{i:1;s:10:"تجربة";i:2;s:4:"test";} >> and that solve the problem ,the messeges that were in the custom folders appear in the new folders names.

    I'm ok to update the effected records one by one, but I need a guidline from you how to deal with the content, is it ok to update all the fields with the apove data? what if there is only one folder ? or more than 3 ?
    You can have folders with the same name, so I would just do this:

    For every instance of
    Code:
    s:NUMBER:"TEXT";
    replace it with
    Code:
    s:14:"Renamed folder"
    Where 14 is the number of characters in the name you are going to use.

    So if you have a user with the following data:
    Code:
    a:2:{i:1;s:6:"[FONT=&quot]الوارد[/FONT]";i:2;s:6:"[FONT=&quot]الصادر[/FONT]";}
    Change it to:

    Code:
    a:2:{i:1;s:14:"Renamed folder";i:2;s:14:"Renamed folder";}
    Then the users should be able to rename their folders themselves.

    Be sure to back up your database before trying this, and/or try it on a test installation first.

    Leave a comment:

  • David Grove
    Senior Member

  • David Grove
    replied
    The fatal error about unsupported operand types is because the serialized PM folder data is corrupted and couldn't be unserialized. The error comes because you try to use the array union operator (+) on something that is not an array. Now, how did the data become corrupted? That must have to do with changing the character encoding. I created a few random folders and printed the contents of $vbulletin->userinfo[pmfolders] a few lines above the unserialize call in functions_user.php. For example this is valid serialized data:

    a:7:{i:4;s:35:"تجربة";i:5;s:43:"fdsaتجربةafds";i:7;s:5:"Inbox";i:6;s:5:"inbox";i:1;s:3:"on e";i:3;s:5:"three";i:2;s:3:"two";}

    Now, I can generate the error by doing a str_replace on the serialized data before it gets unserialized:

    Code:
    $vbulletin->userinfo['pmfolders'] = str_replace('s:35', 's:30', $vbulletin->userinfo['pmfolders']);
    Which will now cause the error, since the data can't be unserialized correctly.

    I believe the root problem is that the folder data was serialized under one character encoding and unserialized under another. I think the string length (s:NUM) is different depending on the character encoding.

    The solution is probably to move everyone's PMs to their inbox and then remove everyone's custom folders (via queries), and have them re-create their folders. Something like that, although this might be cached as well and that would need to be dealt with.

    You could also make a file edit to suppress the fatal error:

    PHP Code:
    // change this
    if (!empty($vbulletin->userinfo['pmfolders']))
    {
        
    $pmfolders $pmfolders unserialize($vbulletin->userinfo['pmfolders']);
    }

    // to this
    if (!empty($vbulletin->userinfo['pmfolders']))
    {
        
    $cachedpmfolders unserialize($vbulletin->userinfo['pmfolders']);
        if (
    is_array($cachedpmfolders) AND !empty($cachedpmfolders))
        {
            
    $pmfolders $pmfolders $cachedpmfolders;
        }
        unset(
    $cachedpmfolders);

    Leave a comment:


  • Mansour
    replied
    Hi
    I did many tests and I hope I can find a guidline to solve this problem.
    1- I update the s value to be 10 and 4 (match with above one that work) >> did not solve the problem.

    2- I delete all the field content >> the pm page open without any problem but the messeges that were in the custom folders did not appear.

    3- I update the filed with other content (the above one that work) : a:2:{i:1;s:10:"تجربة";i:2;s:4:"test";} >> and that solve the problem ,the messeges that were in the custom folders appear in the new folders names.

    I'm ok to update the effected records one by one, but I need a guidline from you how to deal with the content, is it ok to update all the fields with the apove data? what if there is only one folder ? or more than 3 ?

    Leave a comment:

widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X