Forums / Upgrading from 1.3.x to 1.3.9 / strrpos() expects parameter 1 to be string, array given in functions_categories.php

strrpos() expects parameter 1 to be string, array given in functions_categories.php

Results 1 to 14 of 14
11 Feb 2011, 05:54
#1
kashyyyk avatar

kashyyyk

New Zenner

Join Date:
Feb 2009
Posts:
46
Plugin Contributions:
0

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
[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

// 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
11 Feb 2011, 14:28
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Posts:
62,757
Plugin Contributions:
1

Re: strrpos() expects parameter 1 to be string, array given in functions_categories.php

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?
11 Feb 2011, 17:20
#3
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Posts:
21,876
Plugin Contributions:
6

Re: strrpos() expects parameter 1 to be string, array given in functions_categories.php

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.
12 Feb 2011, 00:48
#4
kashyyyk avatar

kashyyyk

New Zenner

Join Date:
Feb 2009
Posts:
46
Plugin Contributions:
0

Re: strrpos() expects parameter 1 to be string, array given in functions_categories.php

Doing the search I got the following response
-

/ /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
12 Feb 2011, 04:57
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Posts:
62,757
Plugin Contributions:
1

Re: strrpos() expects parameter 1 to be string, array given in functions_categories.php

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 ...
12 Feb 2011, 05:08
#6
kashyyyk avatar

kashyyyk

New Zenner

Join Date:
Feb 2009
Posts:
46
Plugin Contributions:
0

Re: strrpos() expects parameter 1 to be string, array given in functions_categories.php

Ok, I'll try that, would it be any of the pages listed from the search inquiry, or any page at all.

Dan
12 Feb 2011, 05:24
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Posts:
62,757
Plugin Contributions:
1

Re: strrpos() expects parameter 1 to be string, array given in functions_categories.php

Those are the pages using the function ... they might help you determine where the paramater values are incorrect for the function ...
12 Feb 2011, 22:29
#8
kashyyyk avatar

kashyyyk

New Zenner

Join Date:
Feb 2009
Posts:
46
Plugin Contributions:
0

Re: strrpos() expects parameter 1 to be string, array given in functions_categories.php

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
12 Feb 2011, 22:42
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: strrpos() expects parameter 1 to be string, array given in functions_categories.php

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.
13 Feb 2011, 01:45
#10
kashyyyk avatar

kashyyyk

New Zenner

Join Date:
Feb 2009
Posts:
46
Plugin Contributions:
0

Re: strrpos() expects parameter 1 to be string, array given in functions_categories.php

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
13 Feb 2011, 04:30
#11
kashyyyk avatar

kashyyyk

New Zenner

Join Date:
Feb 2009
Posts:
46
Plugin Contributions:
0

Re: strrpos() expects parameter 1 to be string, array given in functions_categories.php

I compared files, everything I can tell is fine. It's from an add on, and it's from a page added, since the original install doesn't have a file to compare it to I don't know which file added is causing the problem.

My main page doesn't cause an error, when you are at the items page you don't get the error, now when I go to the catagory page that lists all the items in that catagory, I get the error, I noticed in the section that says "New Products For February - CATAGORY" The word catgory is from the wrong catagory I am in.

Which files create the New product areas and that listing page?
14 Feb 2011, 03:22
#12
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Posts:
21,876
Plugin Contributions:
6

Re: strrpos() expects parameter 1 to be string, array given in functions_categories.php

Do you know what addon mods are installed on your site? You should. If not, what functions related to categories are different in Classic and in your custom template? Do you get the category name error in Classic? That would indicate a mod erroneously installed in /template_default/, or a corrupted file.
05 May 2011, 01:32
#13
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Posts:
1,562
Plugin Contributions:
47

Re: strrpos() expects parameter 1 to be string, array given in functions_categories.php

I'm finding this same issue sporadically across Zen Cart sites ranging from 1.3.8a to 1.3.9h. The site with 1.3.9h only has Fast and Easy AJAX Checkout installed.

A band-aid solution may be to add something like this before the problematic line in functions_categories.php:

[PHP]if (is_array($categories_id)) $categories_id = implode('_', $categories_id);[/PHP]

This assumes that if $categories_id is an array, then it's an array of category ids.
05 May 2011, 02:48
#14
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: strrpos() expects parameter 1 to be string, array given in functions_categories.php

Possibly.

It would be useful to know what specific "clicks" trigger the error so we can trace back the cause of invalid data being submitted to the function.