Announcement

Collapse
No announcement yet.

Fatal error: Unsupported operand types in usercp and PM

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Fatal error: Unsupported operand types in usercp and PM

    Hi
    I have a problem with my vbulletin. Recently I change the encoding in my forum from windows-1256 to utf-8 by iconv command. After that some member face a problem in usercp file and pm. when they visit the page they face this error message :

    Fatal error: Unsupported operand types in /home/mywebuser/public_html/forum/includes/functions_user.php on line 229

    I face a problem with customavatar and socialgrouppicture becuse it was stored in db and when I change the encoding it had damaged. I solved this problem my changing the store type to file system and then overwrite the old pictures (retrieved from old back up DB) on the new one.

    This problem with only some users and they face the error on this two pages :
    • usercp.php
    • private.php

    Do you have any suggestion?

  • #2
    Line 229 in that file is:

    Code:
    		$pmfolders = $pmfolders + unserialize($vbulletin->userinfo['pmfolders']);
    It looks like there might be a problem with the data in the usertextfield.pmfolders field.

    Comment


    • #3
      Hi
      It seems any user create a custom pm folder face this problem.
      I checked this field with the users who have a problem, I don't think it related to the encoding issue! the field looks fine! it is written in Arabic with the correct encoding:
      a:2:{i:1;s:6:"الوارد";i:2;s:6:"الصادر";}
      I also checked with the old DB and it is contain the same data but with different encoding.

      is the problem related to the upgrade ?
      for troubleshooting I try to create a new custom folder for me and this what I get in the usertextfield.pmfolders field :
      a:2:{i:1;s:10:"تجربة";i:2;s:4:"test";}

      the different between this and the previous one is the s value !!

      Comment


      • #4
        Does it work when the custom folders have English names?

        I can't think of any other possible explanations for this. This thread also has several things you can check regarding character encodings:

        http://www.vbulletin.com/forum/showthread.php?t=259250

        Comment


        • #5
          Hi
          No it doesn’t, I update the usertextfield.pmfolders on one user who face this problem, I changed the text from Arabic to English :
          a:2:{i:1;s:6:"INBOX";i:2;s:6:"OUTBOX";}
          but the problem still appear on his pm page!

          is there any other possible causes for this problem?

          Comment


          • #6
            I am out of ideas.

            Changing the encoding of your forum can be problematic and can sometimes result in minor data loss. This third party utility can help:

            http://vcharset.com/

            Comment


            • #7
              if I empty this field is it will help? I mean I want to cancel all the custom folders (not the messege that inside)

              Comment


              • #8
                That is one option. But I'm not sure if that will orphan the associated PMs or not. You should backup and test this first.

                Comment


                • #9
                  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 ?

                  Comment


                  • #10
                    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);

                    ~~~~~

                    Comment


                    • #11
                      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.
                      ~~~~~

                      Comment


                      • #12
                        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,

                        Comment


                        • #13
                          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 ?
                          http://www.shmmr.net/vb/images/image...ar_add2007.gif

                          Comment


                          • #14
                            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.
                            פורומים | קהילת פורומים | פורום | סאמפ | SAMP | GTA

                            Comment


                            • #15
                              i also have this error. though the script above not helping me.

                              any ideas , someone ?
                              בגרות במתמטיקה | פתרונות לספרי לימוד

                              Comment

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