There's a bug report on the ubercart.org forums: http://www.ubercart.org/forum/bug_reports/30467/anonymous_users_cant_acc...

currently, in uc_node_checkout_module function uc_node_checkout_load_cart_item($nid) {}:

$result = db_query("SELECT * FROM {uc_cart_products} WHERE data LIKE '%%\"node_checkout_nid\";i:%d;%%'", $nid);

..this has not been updated for Drupal 7(the place holders are now done using the same syntax as PDOs (:nid)):

like this..?:

$result = db_query("SELECT * FROM {uc_cart_products} WHERE data LIKE '%%\"node_checkout_nid\";i::nid;%%'", array(':uid' => $nid));

Comments

TR’s picture

Status: Active » Closed (duplicate)

That was just updated for Drupal 7 a few hours ago, coincidentally. Please download the new -dev and try again.

http://drupalcode.org/project/uc_node_checkout.git/commitdiff/8efcab2

danlanglois’s picture

http://drupalcode.org/project/uc_node_checkout.git/commitdiff/8efcab2

@@ -1139,7 +1139,7 @@ function uc_node_checkout_load_cart_item($nid) {
     $result = db_query("SELECT * FROM {uc_cart_products} WHERE data LIKE '%%\"node_checkout_nid\";i:%d;%%'", $nid);
 
     // If a matching product was found in the DB for this node...
-    if ($item = db_fetch_object($result)) {
+    if ($item = $result->fetch()) {
       $item->data = unserialize($item->data);
       $items[$nid] = $item;
     }

the line that is in question for me, is still there, line 1139:
$result = db_query("SELECT * FROM {uc_cart_products} WHERE data LIKE '%%\"node_checkout_nid\";i:%d;%%'", $nid);

'Argument 2 passed to db_query() must be an array, string given, called in C:\Users\Studio\Documents\My Web Sites\drupal-7.10\sites\all\modules\uc_node_checkout\uc_node_checkout.module on line 1139'

danlanglois’s picture

Status: Closed (duplicate) » Needs work
TR’s picture

Status: Needs work » Closed (duplicate)

I cited the wrong commit above. That line was indeed fixed already - did you download the new -dev release and check?

LarsKaae’s picture

Assigned: Unassigned » LarsKaae
Status: Closed (duplicate) » Closed (won't fix)

HI,

tried the above update, but then get this message:

Fatal error: Call to a member function fetch() on a non-object in C:\Users\Studio\Documents\My Web Sites\drupal-7.10\sites\all\modules\uc_node_checkout\uc_node_checkout.module on line 1142

I'm still trying to get anonymous user to see my products.... all other works.

it's great job here!

danlanglois’s picture

Assigned: LarsKaae » Unassigned
Status: Closed (won't fix) » Needs work

Yes, I downloaded the new dev release and checked.

To be clear, that means I downloaded the 1-27 dev release, of course that's today.

Also, should this issue ever have been closed (duplicate), w/out citing the duplicate--stipulating that there is one? (and closed again. as a duplicate.).

And as to its now being a status: 'closed (won't fix)' that is assigned to LarsKaae, I think that's an error, I'm unnassigning, but reopening as 'needs work'.

I'm beginning to wonder if I'm contributing to the problem (tends to be the case)?

danlanglois’s picture

Note, the tar has been updated. There is a discrepancy between the tar and the zip file linked (ftp) on the project page.

http://ftp.drupal.org/files/projects/uc_node_checkout-7.x-2.x-dev.zip

This one only, is updated.
http://ftp.drupal.org/files/projects/uc_node_checkout-7.x-2.x-dev.tar.gz

danlanglois’s picture

This is what is there:

<i><b>$result = db_query('SELECT * FROM {uc_cart_products} WHERE data LIKE :nid', array(':nid' => '%\"node_checkout_nid\";i:' . $nid . ';%'))->fetchField();</b></i>

    // If a matching product was found in the DB for this node...
   <b><i> if ($item = $result->fetch()) {</b></i>
      $item->data = unserialize($item->data);
      $items[$nid] = $item;
    }
    else {
      $items[$nid] = FALSE;
    }

as there is no member function fetch() on $result, I think it want to be simply this:
if ($item = $result) {..}

danlanglois’s picture

btw syntax like this, assignment inside a condition, is not for the fainthearted..

LarsKaae’s picture

i'm a newbie, sorry

Still have the above bug after updating the 1 27 dev .tar file

LarsKaae’s picture

Status: Needs work » Closed (fixed)

It's seems to working now.... :-)

I can see the products as anonymous user and as aut.user.

I've just setting the right settings in node-checkout/settings:

I've unchecked these settings:
Redirect customers to their cart when they try to view a node governed by node checkout.
Users who have "edit node_type content" permission are exempt from this redirect.

Sorry for the convenience - it's a grat job you all doing.

Thanks!

summerg’s picture

I am having the same problem and checked the function uc_node_checkout_load_cart_item to confirm I had the most recent copy. All is good, but same error. I noticed $nid is null when it gets to that point... Still looking around.

gregaltuna’s picture

Same problem. Error states:

Fatal error: Call to a member function fetch() on a non-object in /home/content/31/9447231/html/clients/saleo/sites/all/modules/uc_node_checkout/uc_node_checkout.module on line 1142

Node ID is not null in the URL. Have unchecked the suggested setting, and others, and still the error. Any updates? Anyone else still experiencing this problem? I have all the most recent updates installed.

glennnz’s picture

Status: Closed (fixed) » Active

+1

Both the latest dev version and the one referenced in #7 have this error.

sreekanth1201’s picture

Ya, even i got the same error...I used the above referenced verson ut even havng the same error..

stadulis66’s picture

Has anybody figured this out yet. Node checkout and attribute module are conflicting and I can't figure it out.

klausson’s picture

I'm getting the same fatal error claiming a fetch on a non-object. Upon inserting some debug lines, I found that the problem is likely caused by an empty nid being passed to the function from this line (417) within _form_alter:

if ($item = uc_node_checkout_load_cart_item($form['nid']['#value'])) {

The nid being empty is not that surprising since I use node checkout for to create an order in conjunction with node/add. However, I've been doing the exact same thing in D6 and it worked fine. I also compared the code and it doesn't look like it has changed. So whatever trips it up seems to be due to changes in Ubercart or Drupal.

klausson’s picture

One more note: IMHO, the priority should not be "normal", it should at least be major, if not critical since the resulting behavior makes the module unusable.

seanenroute’s picture

Try going to /admin/store/settings/node-checkout/settings and unchecking "Redirect customers to their cart when they try to view a node governed by node checkout."