I just now upgraded from rc6 of Ubercart to rc7 and for some reason i'm getting this error.
[code]
* warning: Invalid argument supplied for foreach() in C:\websites\tlservices\ic\sites\all\modules\ubercart\uc_attribute\uc_attribute.module on line 472.
* warning: Invalid argument supplied for foreach() in C:\websites\tlservices\ic\sites\all\modules\ubercart\uc_attribute\uc_attribute.module on line 472.
[/code]
I haven't changed my php install in any way so I don't understand why something that was suppressed is now throwing a warning. as far as I can tell on that line, the $item->data['attribute'] is coming out as NULL, which is curious on why it didn't throw a warning previously but is now throwing 2 warnings.
I uninstalled and re-installed the module (i know this causes me to re-make my attributes and options, but I'm in development phase so i'm not worried), but the warnings are still there.
I'm putting an if statement to detect the null before the foreach and not run the foreach loop if it is null.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | 587958_item_attributes.patch | 596 bytes | Island Usurper |
Comments
Comment #1
leon kessler commentedI'm getting the same error (although mine being on line 471 for some reason).
Is there a way to fix this or a patch coming out? Should I try an older version of Ubercart?
Comment #2
Island Usurper commentedWhat are you doing when this error shows up? I needs me some context.
Comment #3
leon kessler commentedIt happens whenever the Attributes module is enabled, it appears as soon as I enable the module and on every page throughout the drupal site.
Thanks
Comment #4
Island Usurper commentedI bet the errors will go away if you empty out your cart. That's not a perfect solution, though, because the code should be making sure that items in the cart have at least an empty array of attributes first.
Comment #5
aaronbaumanNope, emptying the cart, then clearing the cache, then re-adding doesn't fix it.
Comment #6
Island Usurper commentedIf you look in the database table uc_cart_products, does the data column have the word "attributes" in it? What kind of gibberish comes right after it?
Comment #7
aaronbaumanthere is no "attributes" index in the serialized array.
Here is the contents of the data column of a particular row:
a:10:{s:10:"ticket_sku";s:7:"Org-Reg";s:11:"ticket_name";s:32:"Registration for an Organization";s:11:"ticket_type";s:1:"1";s:12:"ticket_price";s:3:"195";s:12:"ticket_limit";s:2:"20";s:14:"ticket_enabled";s:1:"1";s:12:"ticket_start";s:1:"0";s:10:"ticket_end";s:1:"0";s:3:"nid";s:4:"9596";s:6:"module";s:10:"uc_product";}
(ticket_* indexes are from my own module).
In fact i'm not even *using* any attributes, which is partly why this is so disconcerting.
Comment #8
Island Usurper commentedAh, but if the attributes module is enabled, there should at least be spot for it in the data array. That's why I told you to empty your cart. When you added the products back to the cart, the attribute module should have put an empty array there. I would review your ticket module to make sure it isn't overwriting the cart item's data array at any point. It should try to only add stuff to it.
Comment #9
torgospizzaI had the same issue; emptying the cart worked.
Comment #10
aaronbaumanMy module is not overwriting the cart item's data array at any point,
but it is adding the item manually (I'm constructing my own data array without any "attribute" index).
Is there a method other than
uc_cart_add_itemI should be using to add my own item?I thought I was doing this right before, so before I re-rtfm, can you point me to a good resource?
Thanks for your help, IU.
Comment #11
graper commentedI think the only reason mine was on a different line was I had gone in there to put in a line to output what was in the variable if anything to the watchdog.
Granville
Comment #12
graper commentedIsland Usurper
My only problem with this statement is that this notice shouldn't be popping up just because the module is turned on. If having an item in the cart can product an object without the attribtues element shouldn't this be tested for and prevented? Think about like this. I have to turn on the module/upgrade UC on a live production site and I have to empty all the carts out there before customers get back to the site to see the message? that doesn't sit well with me and I don't think you want your customers being mad when the cart they just filled up and needed to come back to and finalize for purchase finds it gone.
Granville
Comment #13
Island Usurper commentedaaronbauman, when you use uc_cart_add_item(), the $data parameter should populated with module_invoke_all('add_to_cart_data', $form_state['values']). hook_add_to_cart_data() is where uc_attribute adds the attributes array. It does that based on the attribute fields in the add to cart form. Since you're putting the product into the cart manually, you can fake the form values with
graper, yeah, the easiest solution is just to not assume that the attributes will be in the data array. I'll write a patch up and post it.
Comment #14
tommeir commentedHi there,
I get this error on a fresh install of drupal 6.14 and UC2rc7.
I have only one product node and even though attributes is enabled it has no say with it.
The error appears even if the cart is empty.
pls help this error is driving me crazy.
Comment #15
Island Usurper commentedHere's a patch.
Comment #16
fenstratThat simple cast does the job.
Comment #17
Island Usurper commentedGreat. Committed. Thanks.