Page 1 of 1

unserialize(): Error at offset 0

Posted: Fri Jan 29, 2016 10:17 pm
by Rob Assink
Hi there,

My error log is showing some errors and I am not able to solve them. I looked on the internet but with no succes. Contacted the developer but they do not reply. Is there somebody here who can guide me in the right direction?

The error logs shows the following errors,

PHP Notice: unserialize(): Error at offset 0 of 28 bytes in /var/www/vhosts/subsupply.eu/httpdocs/store/catalog/controller/ne/cron.php on line 1132
PHP Notice: unserialize(): Error at offset 0 of 1641 bytes in /var/www/vhosts/subsupply.eu/httpdocs/store/catalog/controller/ne/cron.php on line 1132

The code on line 1132 is,
1132: $this->config->set($setting['key'], unserialize($setting['value']));

I am using OC 2.1.0.1

Regards,

Rob

Re: unserialize(): Error at offset 0

Posted: Mon Feb 01, 2016 11:59 pm
by Randem
This is the way it is done now in index.php (v2.1.x)

Code: Select all

// Settings
$query = $db->query("SELECT * FROM " . DB_PREFIX . "setting WHERE store_id = '0'");

foreach ($query->rows as $setting) {
	if (!$setting['serialized']) {
		$config->set($setting['key'], $setting['value']);
	} else {
		$config->set($setting['key'], json_decode($setting['value'], true));
	}
}
This is the way is was done in v1.5.x

Code: Select all

// Settings
$query = $db->query("SELECT * FROM " . DB_PREFIX . "setting WHERE store_id = '0' OR store_id = '" . (int)$config->get('config_store_id') . "' ORDER BY store_id ASC");

foreach ($query->rows as $setting) {
	if (!$setting['serialized']) {
		$config->set($setting['key'], $setting['value']);
	} else {
		$config->set($setting['key'], unserialize($setting['value']));
	}
}
As you can see the way you have it in the cron extension is for v1.5.x and will not work in v2.1.x. Now just replacing the line may not work for I have no idea of what else they are doing from v1.5.x or why they are not using the information already gotten from the index.php file.

Re: unserialize(): Error at offset 0

Posted: Tue Feb 02, 2016 1:57 am
by Rob Assink
Yes, it's the version from 1.5 they are using. I will change the code and see what will happen. Thank you anyway so far.

Re: unserialize(): Error at offset 0

Posted: Tue Feb 02, 2016 11:13 am
by Randem
You are aware that 1.5 extensions may not work properly in v2.1.x (mostly do not).

Re: unserialize(): Error at offset 0

Posted: Tue Feb 02, 2016 3:03 pm
by Rob Assink
Yes I am aware of that and it did not work.
I finally managed to get in contact with the developer and he will have a look into it. Hopefully he will solve my problem and if not I need somebody else to fix it for me. Thank you very much so far.

Re: unserialize(): Error at offset 0

Posted: Fri Feb 12, 2016 4:45 pm
by Rob Assink
Problem has been solved by the developer and my hoster. Extension was not completely ready for OC2.1 Thanks for the help

Re: unserialize(): Error at offset 0

Posted: Fri Aug 18, 2017 5:13 pm
by mupcku
Hi folks! I have the same problem! Error is "PHP Notice: unserialize(): Error at offset 0 of 2 bytes in ..." This error is in quickcheckout module, where the client is registering their profile while completing the order, but this is making a problem in my system and the products are not showing in the order! This is the code where the notice is shown

Code: Select all

if ($this->customer->isLogged()) {
				$customer_info = $this->model_account_customer->getCustomer($this->customer->getId());

				$data['customer_id'] = $this->customer->getId();
				$data['customer_group_id'] = $customer_info['customer_group_id'];
				$data['firstname'] = $customer_info['firstname'];
				$data['lastname'] = $customer_info['lastname'];
				$data['email'] = $customer_info['email'];
				$data['telephone'] = $customer_info['telephone'];
				$data['fax'] = $customer_info['fax'];
				$data['custom_field'] = unserialize($customer_info['custom_field']);

			} elseif (isset($this->session->data['payment_address']) && isset($this->session->data['payment_address']['firstname'])) {
				$data['customer_id'] = 0;
				$data['customer_group_id'] = $this->session->data['payment_address']['customer_group_id'];
				$data['firstname'] = $this->session->data['payment_address']['firstname'];
				$data['lastname'] = $this->session->data['payment_address']['lastname'];
				$data['email'] = $this->session->data['payment_address']['email'];
				$data['telephone'] = $this->session->data['payment_address']['telephone'];
				$data['fax'] = $this->session->data['payment_address']['fax'];
				$data['custom_field'] = $this->parseCustomFields($this->session->data['payment_address'], 'account');
			} else { // ->this is the row!!!!
				return false; 
			}

How can i fix it?