strrpos() expects parameter 1 to be string, array given in functions_categories.php
I just upgraded to 1.3.9h, my cache file suddenly filled up myDebug logs.
What it says is
Quote:
[11-Feb-2011 05:29:24] PHP Warning: strrpos() expects parameter 1 to be string, array given in /EDITED/includes/functions/functions_categories.php on line 484
Here are lines 477-514
Code:
// Get all products_id in a Category and its SubCategories
// use as:
// $my_products_id_list = array();
// $my_products_id_list = zen_get_categories_products_list($categories_id)
function zen_get_categories_products_list($categories_id, $include_deactivated = false, $include_child = true, $parent_category = '0', $display_limit = '') {
global $db;
global $categories_products_id_list;
484 $childCatID = str_replace('_', '', substr($categories_id, strrpos($categories_id, '_')));
$current_cPath = ($parent_category != '0' ? $parent_category . '_' : '') . $categories_id;
$sql = "select p.products_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c
where p.products_id = p2c.products_id
and p2c.categories_id = '" . (int)$childCatID . "'" .
($include_deactivated ? " and p.products_status = 1" : "") .
$display_limit;
$products = $db->Execute($sql);
while (!$products->EOF) {
$categories_products_id_list[$products->fields['products_id']] = $current_cPath;
$products->MoveNext();
}
if ($include_child) {
$sql = "select categories_id from " . TABLE_CATEGORIES . "
where parent_id = '" . (int)$childCatID . "'";
$childs = $db->Execute($sql);
if ($childs->RecordCount() > 0 ) {
while (!$childs->EOF) {
zen_get_categories_products_list($childs->fields['categories_id'], $include_deactivated, $include_child, $current_cPath, $display_limit);
$childs->MoveNext();
}
}
}
return $categories_products_id_list;
}
Any idea why this error is occuring?
I upgraded from 1.3.8, by doing a new install with a new database, I then moved all my stuff into the new database, deleted my old files and moved the new files into their place and I kept the new data base. The only thing I've added afterwards is the Facebook open graph add on.
Side note, I just put my site in down for Maintenance and I'm not getting any error logs
Dan
Re: Function_Catagories.php myDebug errors
If you go to the Tools ... Developers Tool Kit ... and in the bottom input box enter:
zen_get_categories_products_list
Select Catalog ... and click Search ...
What files do you see using this function and how are they calling it?
Re: Function_Catagories.php myDebug errors
strrpos($categories_id, '_') thinks it is getting a number when it wants a string. Normally, this works automatically, but if something has referenced $categories_id as a number just before the function is called, it could misfire.
Re: Function_Catagories.php myDebug errors
Doing the search I got the following response
-
Quote:
/ /includes/functions/functions_categories.php
Line #479 : // $my_products_id_list = zen_get_categories_products_list($categories_id)
Line #480 : function zen_get_categories_products_list($categories_id, $include_deactivated = false, $include_child = true, $parent_category = '0', $display_limit = '') {
Line #507 : zen_get_categories_products_list($childs->fields['categories_id'], $include_deactivated, $include_child, $current_cPath, $display_limit);
/ /includes/modules/featured_products.php
Line #31 : $productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);
/ /includes/modules/new_products.php
Line #30 : $productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);
/ /includes/modules/specials_index.php
Line #31 : $productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);
/home/www/phryz.com/includes/modules/upcoming_products.php
Line #33 : $productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);
Dan
Re: Function_Catagories.php myDebug errors
Well ... that is where you should see the calls to it ... I am not seeing the cause of this ...
The best thing to do would be to check the files on the server with a clean Zen Cart v1.3.9h with something like Beyond Compare from scootersoftware.com and see if you can see any damaged, missing or otherwised altered files that might be causing this ...
Re: Function_Catagories.php myDebug errors
Ok, I'll try that, would it be any of the pages listed from the search inquiry, or any page at all.
Dan
Re: Function_Catagories.php myDebug errors
Those are the pages using the function ... they might help you determine where the paramater values are incorrect for the function ...
Re: Function_Catagories.php myDebug errors
I'm going to start comparing later tonight or tomorrow, and I'm looking for a hint on what to look for if possible.
I'm in maintance mode and it has generated no myDebug errors since I've been in that mode, I can move around my site and do searches and all and I get no myDebug errors, now when I ran that search query it generated 5 myDebug errors, I'm assuming once for each of the pages it returned.
I'm hoping that will help
Thanks
Dan
Re: Function_Catagories.php myDebug errors
If the admin search is generating MORE error logs, then it's very likely that the DETAILS of those errors are different than the ones which were triggered by trying to draw the categories list on your storefront.
Re: Function_Catagories.php myDebug errors
I just ran it again to see what the errors are and none generated, it must have been 5 I missed when clearing out the cache