I get the following warning every time I load a page on my website.
warning: unserialize() expects parameter 1 to be string, array given in unserialize() (line 431 of /public_html/sites/all/modules/smsframework/modules/sms_user/sms_user.module).

After some searching I tried the following code

starting at line 429

  $account->sms_user = array();
  while ($data = db_fetch_array($result)) {
++	drupal_set_message(dprint_r($account->data, 1)); 
	$user_data = unserialize($account->data);
	$account->sms_user = $user_data['sms_user'];
	$account->sms_user['number'] = $data['number'];
	$account->sms_user['status'] = $data['status'];
	$account->sms_user['code'] = $data['code'];
	$account->sms_user['gateway'] = unserialize($data['gateway']);
  }

and it gave me the information below

Array
(
    [contact] => 1
    [picture_delete] => 0
    [picture_upload] => 
    [roles_assign] => Array
        (
            [3] => 0
            [7] => 0
        )

    [roles_preserve] => Array
        (
            [2] => 2
            [4] => 4
        )

    [messaging_default] => sms
    [notifications_send_interval] => 0
    [notifications_auto] => 1
    [block] => Array
        (
            [user] => Array
                (
                    [3] => 0
                )

        )

    [force_password_change] => 0
    [sms_user] => Array
        (
            [number] => 
            [status] => 
            [gateway] => 
            [code] => 
        )

)

Since I don't know much about PHP I'm guessing that since the admin account doesn't have any SMS data stored that it is trying to unserialize an empty arrray? If anyone has an good way to fix this please let me know.

Comments

mfb’s picture

You'll have to figure out why $account->data is already unserialized. This is not expected. It should be a serialized string, which could be unserialized to an array.

NROTC_Webmaster’s picture

Do you have any suggestions for how I can find out?

Is it possible just to make it an string again?

Here is one entry from my sms_user table

uid number status code gateway
355 5555555555 2 a:1:{s:7:"carrier";s:23:"messaging.sprintpcs.com";}

So I'm guessing the array it is talking about would be the gateway?

NROTC_Webmaster’s picture

Ok I have been messing with this for days now and if I want to make sure this makes sense.

when I set the it to print the data

	drupal_set_message(dprint_r($data, 1));

I get

Array
(
    [number] => 5555555555
    [status] => 2
    [code] => 
    [gateway] => a:1:{s:7:"carrier";s:23:"messaging.sprintpcs.com";}
)

which should make sense considering it is exactly how it is stored in the database.
But when I print the account data

	drupal_set_message(dprint_r($account, 1));

I get along with a lot of other data about the account

            [sms_user] => Array
                (
                    [number] => 
                    [status] => 
                    [gateway] => 
                    [code] => 
                )

I just dont understand the difference in specifying the account instead of the specific table its coming from. If anyone can help it out I would really appreciate it.

NROTC_Webmaster’s picture

mfb

I think you were right in the fact that it was a problem with another area.

If I use

   drupal_set_message(dprint_r($account->sms_user['number'] . "@" . $account->sms_user['gateway']['carrier'], 1));

as the last line in the while loop it will print the phone number and carrier information.

I just need to figure out what is causing the error to show up and why the carrier information isn't being passed to the email gateway.

NROTC_Webmaster’s picture

Project: SMS Framework » SMS Email Gateway
Version: 6.x-2.x-dev » 6.x-1.0
Component: SMS User » Code

After looking at the sms email gateway I think this belongs in that project.