AbanteCart Community

Shopping Cart Operations => Support => General Support => Topic started by: digitalt on September 23, 2016, 11:59:02 AM

Title: Error with manufacturer.php
Post by: digitalt on September 23, 2016, 11:59:02 AM
This is showing up in error log:

2016-09-23 11:28:41 - warning: AbanteCart core v.1.2.8 Illegal string offset 'start' in <b>/home/digitalt2016/public_html/cbto.us/storefront/model/catalog/manufacturer.php</b> on line <b>66</b>

Also on line 80.

Did some research and it appears that a string is being called as an array. Not a big deal from what I have read, but it could slow down overall performance.  For newbie ecommerce sites, response is of the utmost importance. Ya'all got a simple fix?

Here's the code for that section:
Code: [Select]
$cache_key = 'manufacturer.list.'.md5((int)$data['start'].(int)$data['limit']).'.store_'.$store_id;
$output = $this->cache->pull( $cache_key );

if ($output !== false){
return $output;
}

$sql = "SELECT *
FROM " . $this->db->table("manufacturers") . " m
LEFT JOIN " . $this->db->table("manufacturers_to_stores") . " m2s
ON (m.manufacturer_id = m2s.manufacturer_id)
WHERE m2s.store_id = '" . $store_id . "'
ORDER BY sort_order, LCASE(m.name) ASC";

if ($data['limit']){
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$query = $this->db->query($sql);
$output = $query->rows;
$this->cache->push($cache_key, $output);
return $output;
}

Appears to be the $cache_key string.
Title: Re: Error with manufacturer.php
Post by: Basara on September 26, 2016, 03:00:43 AM
Hello.

What page you visit when error occur?
Title: Re: Error with manufacturer.php
Post by: digitalt on September 26, 2016, 05:47:35 AM
I'm not sure. It seems intermittent.  This is only in A-cart error log and not the server error log.

If I remember correctly, this started showing up after I cloned the default theme into an extension. The only mods I did to the theme were in the style.css and custom.js.

Let me do some checking and I'll get back to you. There were a lot of errors yesterday and I was working on shipping methods. Maybe connected to that?  I'll see if I can recreate the error to a specific page or package.
Title: Re: Error with manufacturer.php
Post by: eCommerce Core on September 26, 2016, 08:46:30 AM
Try this fix
https://github.com/abantecart/abantecart-src/commit/973c0d7bef5ec5b9b2ce1cb6a477e24278653c45

It should fix the warning.
Title: Re: Error with manufacturer.php
Post by: digitalt on September 26, 2016, 12:40:30 PM
That's what's there. Oops, using 1.2.8.

It doesn't cause any real performance issues on Godaddy for me. But wanted to make you aware of it.


Took a closer look today and applied the new code. So far so good.
Title: Re: Error with manufacturer.php
Post by: digitalt on September 27, 2016, 05:06:44 PM
So far the mod works great.

Thanks
Title: Re: Error with manufacturer.php
Post by: digitalt on October 23, 2016, 10:02:22 AM
I've been ignoring this, but also have been getting this error:

2016-10-23 6:43:11 - warning: AbanteCart core v.1.2.8 Illegal string offset 'limit' in <b>/home/digitalt2016/public_html/cbto.us/storefront/model/catalog/manufacturer.php</b> on line <b>83</b>

This is the code starting at line 83:
Code: [Select]
if ($data['limit']){
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$query = $this->db->query($sql);
$output = $query->rows;
$this->cache->push($cache_key, $output);
return $output;
}

I'm guessing the fix is similar to what was already done, but not sure how to do it.
Title: Re: Error with manufacturer.php
Post by: abantecart on October 23, 2016, 01:37:19 PM
I wonder how this happen. Do you have some custom code/extension that calls getManufacturers method with limit passed?

Limit parameter is forced to 0 if negative and converted to int.
Title: Re: Error with manufacturer.php
Post by: digitalt on October 24, 2016, 07:46:08 AM
The only extension I added was Whitelabel and cloned the default template as a new extension. The cloned template only has changes in the .css files and custom.js(no code modifications, only removed some things for a cleaner mobile screen).  Other than that it's a clean installation.

Strange thing is, the error seems random.  If it was serious, there should be an error every time manufacturer.php is called.

I just spent 15 minutes trying to recreate the error to pinpoint it and no luck.  Is there some code I could add to manufacturer.php to log more detail about this?  It's not creating a problem with the site, just a little annoying.
Title: Re: Error with manufacturer.php
Post by: abantecart on November 09, 2016, 09:17:36 AM
Check your Apache log. It it possible that someone is paying with pagination parameters and that will cause this error.
It will not destroy anything. Possibly we can add better error handling in here. 
Title: Re: Error with manufacturer.php
Post by: digitalt on November 09, 2016, 01:48:54 PM
Thanks, I'll check it.
Title: logo changing problem
Post by: gadziraman on November 12, 2016, 03:18:19 PM
hi i am having problem in putting store logo, if i click edit on default template comes blank fields without AbanteCart store logo and icon so there will be no where to click to change the logo , how do i correct the problem. 
Title: Re: Error with manufacturer.php
Post by: digitalt on November 13, 2016, 11:59:15 AM
Just a thought, but could this error be coming from the manufacturers data cache? I have had problems with errors that didn't resolve till I cleared the caches and then everything was okay.

Is there a way to disable manufacturers data cache to test ?