Zen Cart Logo
Forums / Bug Reports / [Done 2.0.0] /includes/classes/shopping_cart.php

[Done 2.0.0] /includes/classes/shopping_cart.php

Locked

Views: 5,252

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
19 Feb 2007, 7:00 PM
#1
blessisaacola avatar

blessisaacola

Totally Zenned

Join Date:
Feb 2004
Location:
Georgia, USA
Posts:
1,875
Plugin Contributions:
1

[Done 2.0.0] /includes/classes/shopping_cart.php

I am not sure if this is a bug or not but the error below is filling up our error log like crazy. Our db was recently upgraded to MYSQL 5.0+ so I am not sure if this related.

PHP Warning: Variable passed to each() is not an array or object in /var/www/html/includes/classes/shopping_cart.php on line 1708

Line 1708 reads: ```php
while ( list( $key, $val ) = each($_POST['products_id']) ) {

19 Feb 2007, 7:17 PM
#2
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,608
Plugin Contributions:
0

Re: [Done 2.0.0] /includes/classes/shopping_cart.php

What version of PHP is installed and what version of Zen Cart are you using?

19 Feb 2007, 7:22 PM
#3
blessisaacola avatar

blessisaacola

Totally Zenned

Join Date:
Feb 2004
Location:
Georgia, USA
Posts:
1,875
Plugin Contributions:
1

Re: [Done 2.0.0] /includes/classes/shopping_cart.php

Kim:

What version of PHP is installed and what version of Zen Cart are you using?

Zen Cart 1.3.7
PHP Version: 5.2.0 (Zend: 2.2.0)
Database: MySQL 5.0.27-standard

19 Feb 2007, 11:31 PM
#4
wilt avatar

wilt

Oji-san

Join Date:
Jun 2003
Location:
Newcastle UK
Posts:
1,867
Plugin Contributions:
3

Re: [Done 2.0.0] /includes/classes/shopping_cart.php

its definitley nt anything to do with mysql 5.

I have a vague suspicion that its something to do with spiders, but will play around with it to see if I can reproduce

12 May 2007, 9:07 PM
#5
blessisaacola avatar

blessisaacola

Totally Zenned

Join Date:
Feb 2004
Location:
Georgia, USA
Posts:
1,875
Plugin Contributions:
1

Re: [Done 2.0.0] /includes/classes/shopping_cart.php

wilt:

its definitley nt anything to do with mysql 5.

I have a vague suspicion that its something to do with spiders, but will play around with it to see if I can reproduce

Any updates? This error is still filling up our error_log
**
[Sat May 12 16:48:13 2007] [error] PHP Warning: Variable passed to each() is not an array or object in /includes/classes/shopping_cart.php on line 1708**

Thanks!

12 May 2007, 9:31 PM
#6
wilt avatar

wilt

Oji-san

Join Date:
Jun 2003
Location:
Newcastle UK
Posts:
1,867
Plugin Contributions:
3

Re: [Done 2.0.0] /includes/classes/shopping_cart.php

HI,

I'm still convinced this is caused by a spider picking up on a posted url.

Code has been committed to bug fix branch to try and address the problem.

If you want to try and adjust your current code then you need to replace your current

function actionMultipleAddProduct
with

  function actionMultipleAddProduct($goto, $parameters) {
    global $messageStack;
    if (is_array($_POST['products_id']) && sizeof($_POST['products_id']) > 0) {
      while ( list( $key, $val ) = each($_POST['products_id']) ) {
        if ($val > 0) {
          $adjust_max = false;
          $prodId = $key;
          $qty = $val;
          $add_max = zen_get_products_quantity_order_max($prodId);
          $cart_qty = $this->in_cart_mixed($prodId);
//        $new_qty = $qty;
//echo 'I SEE actionMultipleAddProduct: ' . $prodId . '<br>';
          $new_qty = $this->adjust_quantity($qty, $prodId, 'shopping_cart');

          if (($add_max == 1 and $cart_qty == 1)) {
            // do not add
            $adjust_max= 'true';
          } else {
            // adjust quantity if needed
            if (($new_qty + $cart_qty > $add_max) and $add_max != 0) {
              $adjust_max= 'true';
              $new_qty = $add_max - $cart_qty;
            }
            $this->add_cart($prodId, $this->get_quantity($prodId)+($new_qty));
          }
          if ($adjust_max == 'true') {
//            $messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . ' C: - ' . zen_get_products_name($prodId), 'caution');
            $messageStack->add_session('shopping_cart', ERROR_MAXIMUM_QTY . zen_get_products_name($prodId), 'caution');
          }
        }
      }
// display message if all is good and not on shopping_cart page
      if (DISPLAY_CART == 'false' && $_GET['main_page'] != FILENAME_SHOPPING_CART) {
        $messageStack->add_session('header', SUCCESS_ADDED_TO_CART_PRODUCTS, 'success');
      }
      zen_redirect(zen_href_link($goto, zen_get_all_get_params($parameters)));
    }
  }

Always ensure you back up files you are changing !!

26 Aug 2007, 9:18 AM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done 2.0.0] /includes/classes/shopping_cart.php

Isaacola,

Is this resolved ? If so, what was the solution?

26 Aug 2007, 7:13 PM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done 2.0.0] /includes/classes/shopping_cart.php

The teamzr1 posts akin to the problem reported above have been moved to their initial thread where more detailed discussion takes place, to keep details together:
http://www.zen-cart.com/forum/showthread.php?t=73800

3 Sep 2007, 3:27 AM
#9
blessisaacola avatar

blessisaacola

Totally Zenned

Join Date:
Feb 2004
Location:
Georgia, USA
Posts:
1,875
Plugin Contributions:
1

Re: [Done 2.0.0] /includes/classes/shopping_cart.php

DrByte:

Isaacola,

Is this resolved ? If so, what was the solution?

Applying the code above seem to have solved the problem.

3 Sep 2007, 7:11 AM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done 2.0.0] /includes/classes/shopping_cart.php

Thanks for the confirmation.
We'll use this or some rendition of it to prevent spiders from triggering unwanted alerts.