warning: key() [function.key]: Passed variable is not an array or object in /Users/williamlinn/Sites/linnsoft/linnsoft/sites/default/modules/uc_dependent_attributes/uc_dependent_attributes.module on line 134.
warning: Invalid argument supplied for foreach() in /Users/williamlinn/Sites/linnsoft/linnsoft/sites/default/modules/uc_dependent_attributes/uc_dependent_attributes.module on line 142.
warning: reset() [function.reset]: Passed variable is not an array or object in /Users/williamlinn/Sites/linnsoft/linnsoft/sites/default/modules/uc_dependent_attributes/uc_dependent_attributes.module on line 153.
I'm getting this multiple times for the function.key and function.reset in lines 134, 142, 153, 154.
It doesn't update whenever I have multiple attributes configured on a given product. It seems to work if I have only one attribute class with several options, but the minute I add another attribute class, then the updates to the page given by this module effectively update the FIRST attribute class correctly always, but any others below it remain stuck in their previous state.
I noticed that when this happens if I click on one of the options in the first attribute class, that the one directly below it then updates. Seems like a looping bug, hopefully an easy fix cause I would love to use this module.
FYI I'm wanting to use this on product classes with preset attribute classes, but I also tested this with a normal UC Product and imported attributes, the same thing is happening. I'm using 4 options in the first attribute class and 3 options in 2 other attribute classes.
-wil
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | delete-remnant-records-683418-20.patch | 2.74 KB | jantoine |
| #19 | invalid_arg-683418.patch | 607 bytes | stevesmename |
| #11 | uc_dependent_attributes-6.x-1.x-683418-invalid-argument-foreach.patch | 830 bytes | wjaspers |
| #10 | uc_dependent_attributes-6.x-1.x-683418-invalid-argument-foreach.patch | 988 bytes | wjaspers |
Comments
Comment #1
TheDarkFlop commentedGetting a similar error when I am on the edit attributes page for the product. ...../node/19/edit/attributes
warning: Invalid argument supplied for foreach() in /nfs/c01/h09/mnt/32879/domains/new.prakprint.com/html/sites/all/modules/ubercart/uc_dependent_attributes/uc_dependent_attributes.module on line 187.
Comment #2
Anonymous (not verified) commentedI have the same error. Anyone have ideas how to fix this?
# warning: Invalid argument supplied for foreach() in C:\wamp\www\Drupal\sites\all\modules\uc_dependent_attributes\uc_dependent_attributes.module on line 186.
This is a very irritating error. Any help at all would be greatly appreciated.
Comment #3
vitis commentedsubscribing
Comment #4
dmurray commentedI'm also receiving this error
Comment #5
SchwebDesign commentedI'm getting the same errors as both blasthaus and dmurray. I suspect it is because i had installed the UC Option Images module which i suspect is somehow not compatible with the uc dependent attributes module. But i'm not sure.... Any thoughts?
I disabled and uninstalled the Option Images module and the problem seemed to have gone away temporarily, but seems to have returned upon installing the devel module and looking at the dev render info for a given product.
Comment #6
wjaspers commentedEven stranger; if I try to go from any of the "UC Product tabs" to the added "Options" list, I get redirected to a different product.
I found a "workaround for it":
"REMOVE" your attributes from the product afflicted.
Add the attributes you want back.
Re-configure your attribute options, and save the product.
This will clean up the glitch.
It appears to be only triggered by leaving a "Default" option which you may have turned OFF after configuring your options list.
Comment #7
Anonymous (not verified) commentedWith over 640 select boxes this is not an option for me. I am tempted to manually edit the table but I am fearful of breaking something.
As it seems to still work I left it as is. Not ideal however.
Comment #8
FranCarstens commentedI'm having the same issue.
I've tried to remove and re-add (new word) the attributes. This did not work.
I've tried to completely replace them with a new set. This did not work.
Right now, I'm stumped and looking at a list of 720 "warning: Invalid argument supplied for foreach()..."
I'm not using Option Images or Devel.
Comment #9
Stan.Ezersky commentedI have the same error
Comment #10
wjaspers commentedIn peering through the code, I can see where this problem is stated to occur.
It looks as if the author's function
array_hierarchycan't tell when an array value contains an array or not.Here's a potential patch for the issue ... I haven't had time to test it, but it should alleviate arrays blowing up in your site(s).
Since PHP4 is officially dead, I added typecasts to some of the author's built-in functions regarding arrays. Typecasting to an array will ensure that whatever value is sent to a "foreach" is valid to loop on. If the value isn't useful, it will simply turn into array( 'value' );
Additional comments are welcome.
OH crap! Winmerge ran the patch backwards. Don't use this one.
Comment #11
wjaspers commentedTry this one instead. Sorry about the confusion.
Comment #12
evronique commentedThis patch doesn't work for me I have always:
* warning: Invalid argument supplied for foreach() in [...]/modules/uc_dependent_attributes/uc_dependent_attributes.module on line 142.
* warning: reset() [function.reset]: Passed variable is not an array or object in [...]/modules/uc_dependent_attributes/uc_dependent_attributes.module on line 153.
* warning: key() [function.key]: Passed variable is not an array or object in [...]/modules/uc_dependent_attributes/uc_dependent_attributes.module on line 154.
Any idea?
Comment #13
wjaspers commentedWell ... back to the drawing board.
I'll take another look at it this weekend, if I have time.
Comment #14
summit commentedSubscribe, having the same problem. Hopefully you can get the solution soon!
Thanks a lot in advance for solving this!
greetings, Martijn
Comment #15
zincdesign commentedSubscribing
Comment #16
RotHorseKid commentedSubscribing
Comment #17
FranCarstens commentedThis issue persists, subscribing.
Comment #18
SchwebDesign commentedsubscribing
Comment #19
stevesmename commentedAttaching patch that I used for a quick fix. Was receiving the same error as in comment #4; this error doesn't do any harm the code just seemed not to properly handle empty arrays.
Comment #20
jantoine commentedThese errors are due to remnant database records not being deleted when product attributes and options are not updated. I have attached a patch that properly hooks into the product update process and cleans up the database. To clean up any existing products, simply save the products 'options' page.
Comment #21
stevesmename commentedI tested the patches above, even my own (#19) and none work. The theories also seem inaccurate.
The code below generates the error, lines 47-66. The $possible array is never generated for attributes that are either checboxes or text fields; if the product doesn't have other attributes that are either select box or radio options, then the array is never built and the error messages are displayed.
The below code attempts to check if $possible is not set so that errors are not thrown. Replace your existing function with below (note this relates to 6.x-1.0).