Forums / Upgrading from 1.3.x to 1.3.9 / Strange "shopping cart" warning in logs

Strange "shopping cart" warning in logs

Locked

Started by quentinjs on 20 Dec 2006, 7:47 AM · Views: 1,593

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
20 Dec 2006, 7:47 AM
#1
quentinjs avatar

quentinjs

Zen Follower

Join Date:
Mar 2004
Location:
Calgary, Alberta
Posts:
289
Plugin Contributions:
0

Strange "shopping cart" warning in logs

**PHP Warning: Variable passed to each() is not an array or object in www.totalgarage.ca\Products\includes\classes\shopping_cart.php on line 1716

Is this a concern or did it work ok for the customer. I was doing testing on a non related project and noticed this in the error logs.

20 Dec 2006, 9:31 PM
#2
drbyte avatar

drbyte

Sensei

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

Re: Strange "shopping cart" warning in logs

Hard to say. If you can't reproduce the problem, it's hard to know for sure.
What version of Zen Cart are you using?
What addons/mods have been applied?
What was the IP address? Does that match the IP address on any of your orders, esp for the date on which the warning occurred.

(Note: It's a PHP warning, not a fatal error, so PHP probably just continued on ... it's uncertain whether the customer would have seen the warning message though)

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

7 Jan 2007, 7:03 AM
#3
quentinjs avatar

quentinjs

Zen Follower

Join Date:
Mar 2004
Location:
Calgary, Alberta
Posts:
289
Plugin Contributions:
0

Re: Strange "shopping cart" warning in logs

I don't seem able to reproduce this myself, but I had 20 logged errors last night and about 15 from the day before. I'm not sure how this is being caused.

Whats the easiest way of trapping this. I have a table called log that I can post messages to, but how to I post the error message.

To answer your questions....

What version of Zen Cart are you using? 1.3.6
What addons/mods have been applied? PriceList and IH2

What was the IP address? Does that match the IP address on any of your orders, esp for the date on which the warning occurred.
No orders are logged that match this.

Below is the actual function, its on the "while" that is the problem. When does this method get called? Might help if I knew how I should try and replicate it.

  function actionMultipleAddProduct($goto, $parameters) {
    global $messageStack;
    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');
        }
      }
    }
// 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)));
  }
7 Jan 2007, 8:11 AM
#4
drbyte avatar

drbyte

Sensei

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

Re: Strange "shopping cart" warning in logs

The actionMultipleAddProduct() function is called when someone clicks the "Add these products to my cart" button.

If it's failing on the each() then the $_POST['products_id'] passed to it is not an array, or in other words, has no usable data of the expected type.

Essentially it's like they're clicking on the Multiple Add to Cart button without choosing anything to add. This would be typical of a spider. However, submitting even with 0's still populates the array properly. So, this would have to be a case where there were NO products listed, but the Multiple Add to Cart button was still displayed and was clicked. That should never happen.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

9 Jan 2007, 5:57 AM
#5
quentinjs avatar

quentinjs

Zen Follower

Join Date:
Mar 2004
Location:
Calgary, Alberta
Posts:
289
Plugin Contributions:
0

Re: Strange "shopping cart" warning in logs

Okay, that makes sense. In otherwords the only way it could occur is if its a spider, or some similar tool so its not a concern I need to worry about.

Thanks!
Off I go back to my nefarious report generator... one day I'll get it done...