dblog:

Referrer https://secure.cfis.com/node/183/webform-results/download
Message Warning: Invalid argument supplied for foreach() in _webform_csv_data_productfield() (line 568 of /var/www/vhosts/secure.cfis.com/modules/commerce_webform/productfield.inc).

I've got 3000+ lines in my dblog for Oct lunch orders:- only 313 SIDs but many product SKUs per student (dozens at times).

  foreach ($options as $key => $item) {
    $index = FALSE;
568    foreach ($values as $value) {
      if ($value->product_id == $key) {
        $index = $value;
      }
    }

Not sure what's not right here. Any ideas? I'd like to shed the warnings :-)

-- Karin

Comments

karing’s picture

Actually some of them log messages are re: line 560 - same message though:

http://cfis.local/node/183/webform-results/download
Warning: Invalid argument supplied for foreach() in _webform_csv_data_productfield() (line 560 of /Applications/MAMP/htdocs/Henrietta/git-7/sites/default/modules/commerce_webform/productfield.inc).
johnennew’s picture

Version: 7.x-1.0-beta6 » 7.x-1.x-dev
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new689 bytes

Hi KarinG - It looks like $values is not always an array. Documentation for the hook says it should always be an array so it would be good to know what it is when the error occurs.

I've not been able to replicate this - can you try the attached patch and see what happens?

karing’s picture

StatusFileSize
new18.37 KB
karing’s picture

Hi! I've uploaded product_skus.png to this node - as you can see I've got 12 product skus and when I debug $values, I get:

{"product_id":10,"quantity":"1","order_id":"10501","line_item_id":"28356","paid":true}
null
null
null
null
null
null
null
{"product_id":"121","quantity":1,"order_id":"10501","line_item_id":"28357","paid":true}
{"product_id":0,"quantity":1,"order_id":false,"line_item_id":false,"paid":false}
{"product_id":0,"quantity":1,"order_id":false,"line_item_id":false,"paid":false}
{"product_id":0,"quantity":1,"order_id":false,"line_item_id":false,"paid":false}

So I'm getting = null for Select elements IF I haven't selected for the product (paid/unpaid status doesn't matter). I'm getting 2 notices in the dblog for every = null, so 14 in total. The drink options are checkboxes and these are working as expected.

I recently changed the #type for Quantity with a 'select' (formerly a textfield) - https://drupal.org/node/2073513 - but reverting that still gives me the same number of:

$values = 0

Curious (and hoping) you can reproduce this by making some products "Allow the user to set the quantity".

-- KarinG

johnennew’s picture

Hi KarinG,

I have replicated the problem. Not sure why there is a NULL going in there but the patch in #2 does appear to stop the issue. Basically, if there is no value return nothing - can you confirm, or is expected data missing from the CSV export?

karing’s picture

Hi! Yes, we can stop the error messages in the dblog by checking to see if $values is an array first (patch in #2) - but w/ that patch I am now missing data from the report. Essentially the $values = null fields are no longer producing a 0 in their cell - everything is now shifted right to left - so data is in the wrong columns and/or no data at all (far right columns).

-- Karin

karing’s picture

StatusFileSize
new67.73 KB

Hi John - I've attached a screenshot to illustrate #6. -- Karin

karing’s picture

Status: Needs review » Needs work
karing’s picture

Hi John,

Hoping you will soon have a chance to think about what to do here. To recap: the patch in #2 does stop the error messages written to the dblog - but the csv is all messed up. I think perhaps we need to rewrite the:

null

to

something like:

{"product_id":0,"quantity":0, etc.

Best for 2014!

-- Karin

johnennew’s picture

Assigned: Unassigned » johnennew
Status: Needs work » Needs review
StatusFileSize
new6.22 KB

Hi Karin,

Found some more time to work on this at the weekend. This issue has thrown up some deeper problems with the module. Can you check the attached, rather larger patch and see how you get on? It's a patch against latest 1.x dev branch - if you are not running the dev branch you might have a problem with this one.

Kind regards,

John

karing’s picture

Hi John, Ah - I see. Thank you. I'll take a cloned copy of the school's site to 1.x dev - apply this patch and run tests. -- Karin

johnennew’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Needs review » Active

Confirmed this is a problem with 7.x-2.x

johnennew’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new5.22 KB

Slight modification of the patch in #10 for the 7.x-2.x branch

  • ceng committed 4f6b346 on 7.x-2.x
    Issue #2100821 by ceng, KarinG: Webform CSV download produces: Warning:...
johnennew’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 7.x-2.x with thanks!

karing’s picture

Great - thank you!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.