With the Nov 2nd dev version, I get this error on every page:

* warning: Invalid argument supplied for foreach() in /home/.jojo/[user]/[mysite.com]/sites/all/modules/uc_discounts_alt/uc_discounts/uc_discounts.module on line 1013.
    * user warning: Unknown column 'a' in 'where clause' query: SELECT DISTINCT tid FROM term_node WHERE nid IN(80,a) in /home/.jojo/[user]/[mysite.com]/sites/all/modules/uc_discounts_alt/uc_discounts/uc_discounts.module on line 1038.
    * user warning: Unknown column 'a' in 'where clause' query: SELECT DISTINCT model FROM uc_products WHERE nid IN(80,a) in /home/.jojo/[user]/[mysite.com]/sites/all/modules/uc_discounts_alt/uc_discounts/uc_discounts.module on line 1053.
    * user warning: Unknown column 'a' in 'where clause' query: SELECT DISTINCT type FROM node WHERE nid IN(80,a) in /home/.jojo/[user]/[mysite.com]/sites/all/modules/uc_discounts_alt/uc_discounts/uc_discounts.module on line 1065.
    * user warning: Unknown column 'a' in 'where clause' query: SELECT DISTINCT d.* FROM uc_discounts d LEFT JOIN uc_discounts_products dp ON d.discount_id=dp.discount_id LEFT JOIN uc_discounts_terms dt ON d.discount_id=dt.discount_id LEFT JOIN uc_discounts_skus ds ON d.discount_id=ds.discount_id LEFT JOIN uc_discounts_classes dcl ON d.discount_id=dcl.discount_id WHERE (d.requires_code=0) AND (d.has_role_filter=0 OR d.discount_id IN(SELECT dr.discount_id FROM uc_discounts_roles dr, users_roles ur WHERE (dr.role_id=ur.rid AND ur.uid=1) OR dr.role_id=-1 OR dr.role_id=2)) AND (d.filter_type<>1 OR dp.product_id IN(80,a,-1)) AND (d.filter_type<>2 OR dt.term_id IN(-1)) AND (d.has_expiration=0 OR d.expiration>0) ORDER BY weight in /home/.jojo/[user]/[mysite.com]/sites/all/modules/uc_discounts_alt/uc_discounts/uc_discounts.module on line 1133.
    * warning: Invalid argument supplied for foreach() in /home/.jojo/[user]/[mysite.com]/sites/all/modules/uc_discounts_alt/uc_discounts/uc_discounts.module on line 1013.
    * user warning: Unknown column 'a' in 'where clause' query: SELECT DISTINCT tid FROM term_node WHERE nid IN(80,a) in /home/.jojo/[user]/[mysite.com]/sites/all/modules/uc_discounts_alt/uc_discounts/uc_discounts.module on line 1038.
    * user warning: Unknown column 'a' in 'where clause' query: SELECT DISTINCT model FROM uc_products WHERE nid IN(80,a) in /home/.jojo/[user]/[mysite.com]/sites/all/modules/uc_discounts_alt/uc_discounts/uc_discounts.module on line 1053.
    * user warning: Unknown column 'a' in 'where clause' query: SELECT DISTINCT type FROM node WHERE nid IN(80,a) in /home/.jojo/[user]/[mysite.com]/sites/all/modules/uc_discounts_alt/uc_discounts/uc_discounts.module on line 1065.
    * user warning: Unknown column 'a' in 'where clause' query: SELECT DISTINCT d.* FROM uc_discounts d LEFT JOIN uc_discounts_products dp ON d.discount_id=dp.discount_id LEFT JOIN uc_discounts_terms dt ON d.discount_id=dt.discount_id LEFT JOIN uc_discounts_skus ds ON d.discount_id=ds.discount_id LEFT JOIN uc_discounts_classes dcl ON d.discount_id=dcl.discount_id WHERE (d.requires_code=0) AND (d.has_role_filter=0 OR d.discount_id IN(SELECT dr.discount_id FROM uc_discounts_roles dr, users_roles ur WHERE (dr.role_id=ur.rid AND ur.uid=1) OR dr.role_id=-1 OR dr.role_id=2)) AND (d.filter_type<>1 OR dp.product_id IN(80,a,-1)) AND (d.filter_type<>2 OR dt.term_id IN(-1)) AND (d.has_expiration=0 OR d.expiration>0) ORDER BY weight in /home/.jojo/[user]/[mysite.com]/sites/all/modules/uc_discounts_alt/uc_discounts/uc_discounts.module on line 1133.
CommentFileSizeAuthor
#19 621918.patch821 bytesezra-g
#14 621918.patch2.03 KBmiguel_angel

Comments

jday’s picture

I get this error:

warning: Invalid argument supplied for foreach() in /home/..../sites/all/modules/uc_discounts_alt/uc_discounts/uc_discounts.module on line 1011.

Abilnet’s picture

I get this error:

warning: Invalid argument supplied for foreach() in /home/..../sites/all/modules/uc_discounts_alt/uc_discounts/uc_discounts.module on line 1011.

I can verify the same error.

attishu’s picture

Same error for me just in the shopping cart...
After I created the first discount. After I deleted, but the error message is same. When I have any item in the cart.
If the item is part of the discount, the module is recognise the rule, write the description on the screen, but the discount is £0.

Invalid argument supplied for foreach() in .../sites/all/modules/uc_discounts_alt/uc_discounts/uc_discounts.module on line 1011.

Zalatar’s picture

These errors are in my logs:

Unknown column 'a' in 'where clause' query: SELECT DISTINCT d.* FROM uc_discounts d LEFT JOIN uc_discounts_products dp ON d.discount_id=dp.discount_id LEFT JOIN uc_discounts_terms dt ON d.discount_id=dt.discount_id LEFT JOIN uc_discounts_skus ds ON d.discount_id=ds.discount_id LEFT JOIN uc_discounts_classes dcl ON d.discount_id=dcl.discount_id WHERE (d.requires_code=0) AND (d.has_role_filter=0 OR d.discount_id IN(SELECT dr.discount_id FROM uc_discounts_roles dr, users_roles ur WHERE (dr.role_id=ur.rid AND ur.uid=0) OR dr.role_id=-1 OR dr.role_id=1)) AND (d.filter_type<>1 OR dp.product_id IN(586,a,-1)) AND (d.filter_type<>2 OR dt.term_id IN(-1)) AND (d.has_expiration=0 OR d.expiration>0) ORDER BY weight in /home/radiator/public_html/sites/all/modules/uc_discounts_alt/uc_discounts/uc_discounts.module on line 1133.

Unknown column 'a' in 'where clause' query: SELECT DISTINCT type FROM node WHERE nid IN(586,a) in /home/radiator/public_html/sites/all/modules/uc_discounts_alt/uc_discounts/uc_discounts.module on line 1065.

Unknown column 'a' in 'where clause' query: SELECT DISTINCT model FROM uc_products WHERE nid IN(586,a) in /home/radiator/public_html/sites/all/modules/uc_discounts_alt/uc_discounts/uc_discounts.module on line 1053.

Unknown column 'a' in 'where clause' query: SELECT DISTINCT tid FROM term_node WHERE nid IN(586,a) in /home/radiator/public_html/sites/all/modules/uc_discounts_alt/uc_discounts/uc_discounts.module on line 1038

I think that was all of them.
Z

dave bruns’s picture

I get the same error as well (warning: Invalid argument ...uc_discounts.module on line 1011.)

Is there a workaround for this - perhaps an earlier dev release that didn't have this issue? I tried beta36 as well, but couldn't manage to configure a role-based discount. I could select role-based filtering, but the available roles would not appear, and the form would therefore not validate on save. Roles-based filtering worked great with the 6.2x dev, but then I ran into the invalid argument problem.

I'm new to alt_discounts, so don't know much about it. I've been testing the uc_discount (discount framework) module, but have not been able to get role based discounts to work all the day through a submitted order. Apparently, the discount framework module is out of synch somewhat with Ubercart 2.0, so it seems that I should wait for it to catch up again.

Thanks in advance for any info.

ezra-g’s picture

Status: Active » Postponed (maintainer needs more info)

Can you describe the kind of discount you have enabled on the site and the types of products in the cart?

ezra-g’s picture

Title: Warning: Invalid argument error » Unknown Column 'a' in Where Clause

Also, I've separated this issue out. Please see #634718: Invalid argument supplied for foreach() uc_discounts/uc_discounts.module on line 233 for the invalid argument error. Let's use this issue for the "Unknown Column 'a' in Where Clause" error. I'm so far unable to reproduce this, so a description of the discount and the products in the cart would be helpful.

Zalatar’s picture

Title: Unknown Column 'a' in Where Clause » Warning: Invalid argument error

I have several discounts enabled but only one of them was being used.
It was a 10 percent discount off all products applied to one role. I am using product price alter field.
The other discounts are basically the same, percents off applied to one role.

Hope this helps,
Z

ezra-g’s picture

Title: Warning: Invalid argument error » Unknown Column 'a' in Where Clause

Thanks, but I'm still not able to reproduce this. Does the error remain if you disable the price alter field?

Also, please don't change the issue title.

Zalatar’s picture

I am not sure, I have since reverted back to v1 for now. I may be ablt to test this tomorrow sometime.
Maybe someone else can reply.
I didn't change the title, it must of been the default.
Z

butler360’s picture

So the new issue you created covers the issue I originally posted about and I should install the patch?

miguel_angel’s picture

Status: Postponed (maintainer needs more info) » Needs work

Hi!

At line 991:

if (!empty($product->data['kit_id'])) {

if $product->data isn't an array then the if condition is true and $product->data['kit_id'] returns an 'a' which is added to the $order_product_ids_set array as a key.

A possible workaround:

if (is_array($product->data) && !empty($product->data['kit_id'])) {

This works and removes the error message but I don't know if this is correct.

ezra-g’s picture

This looks good to me, thanks! Could you format it is a patch so others here can test?

miguel_angel’s picture

StatusFileSize
new2.03 KB

Here is the patch. It also includes the 634718.patch

ezra-g’s picture

Status: Needs work » Needs review

Great, thanks! Marking as needs review.

butler360’s picture

The patch seems to work. I'm not seeing any more errors, at least.

DanielJohnston’s picture

Confirmed that patch at #14 resolves the error in my installation.

ezra-g’s picture

Status: Needs review » Needs work

Thanks for the patch. This patch needs a bit of work before it can be committed. Please use 2 spaces for each indentation per the Drupal coding standards. Also, I applied the fix at #634718: Invalid argument supplied for foreach() uc_discounts/uc_discounts.module on line 233, so the current patch should be re-rolled without that other fix.

Thanks!

ezra-g’s picture

Status: Needs work » Needs review
StatusFileSize
new821 bytes

Actually, here's a re-roll that has the fix that was specific to this issue. Setting back to needs review.

ezra-g’s picture

Status: Needs review » Fixed

Actually, this is committed. Thanks for the help identifying this issue and for the patch reviews. If this doesn't resolve the problem, please re-open this issue.

miguel_angel’s picture

Thanks ezra-g.

I think the patch should include the 991 line modification showed:
if (is_array($product->data) && !empty($product->data['kit_id'])) {
to avoid the dummy 'a' that is causing this error.

Shouldn't it?

ezra-g’s picture

Thanks for pointing this out. I made an additional commit. For future issues, this is the kind of detail that can get lost when 2 patches are combined into one ;). Thanks again for your help here!

Status: Fixed » Closed (fixed)

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