Checkout problem

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

I'm currently trying to pin down a problem with the checkout, and wondered if anyone else has come across it and if it's just a misconfiguration somewhere, or a genuine bug. On a few occasions whilst setting up my store a particular error has crept in which I can't fix except by restoring a previous backup -- even uninstallation and reinstallation of the module doesn't fix it.

What happens is that when an order is submitted, the following screen comes back with none of the tokens filled out (e.g., it says "your order number is .") and showing the checkout message for existing-but-not-logged-in users although the order is submitted whilst logged in. The order status remains "In checkout" and nothing further happens. So far it appears to be independent of workflow-ng settings, but I haven't got any further in finding what triggers it, though my tests have now closed in on the various configuration options in Drupal under the "Site building" menu (however illogical that might be to someone who knows Drupal and Ubercart under the hood).

I'm using CCK and JS Tools and a few other common modules, and I should also point out that it has happened when using a standard Drupal installation with Ubercart and the various required modules added manually on top, as well as with the Drupal + Ubercart pre-mod.

(P.S. Again, this is a great shopping cart...)

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

OK, I have some more information now. It seems only to happen if a certain block is enabled when the "Review order" page is generated. The HTML in the block that causes the trouble is as follows:
<img src="files/images/woodcutborder1.jpg" alt="" style="margin-top: 12ex" />

For some reason this causes the $_SESSION["cart_order"] variable, which exists when the Review order page is generated, to become unset when the order is submitted.

Posts: 5367
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

I'd look elsewhere... and maybe suspect the JS Tools module before something like this. That session variable is supposed to be cleared when you complete an order.

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

The problem is that uc_cart_checkout_review_form_submit() can't load the order at
$order = uc_order_load($_SESSION['cart_order']);
because the session variable is unset. I suppose this must be happening in some hook.

I've now removed all extraneous modules and am left with the following:

Drupal core (no optional modules)
Ubercart core + Payment/Credit Card/Test Gateway
Tables API
Token
uBrowser
Workflow-ng

It still happens, using both Garland and Zen themes. As noted, this has already happened on a couple of different installations, but I will try to reproduce it on a fresh install.

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

I've now managed to reproduce this on a clean install using your distro without any modifications except:

  • enabling the Payment and Credit Card modules
  • inserting the block as stated above (must use Full HTML input format)
  • turning on Clean URLs

The problem requires Clean URLs to manifest.

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

I now see that this is caused by the following on line 1267 of uc_cart.module, which somehow gets called inappropriately:

function uc_cart_view_form_submit($form_id, $form_values) {
  if (isset($_SESSION['cart_order'])) {
    unset($_SESSION['cart_order']);
}

This seems quite bizarre to me. I'm noting the naming similarity in the last 16 characters of uc_checkout_review_form_submit() -- the correct function -- and uc_cart_view_form_submit()

Posts: 2267
Joined: 08/07/2007
AdministratoreLiTe!

This is a long shot, but shouldn't the style end in a semicolon?
style="margin-top: 12px;"

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

It's only required if you're following it with another declaration; but I just tested it for good measure, and it makes no difference.

I just tested the name similarity and that has nothing to do with it.

I tried testing with the Free Order module, but the Ajax bit that fills out that section on the checkout page went into a repeating loop loading a whole Drupal page into that which had the following text: "Test free order: Add discount | Remove discount". I presume I configured it wrong, so I'll try with another payment module.

It seems that the checkout problem persists when using the Contact payment method, so it's probably not related to Credit Card.

I forgot to mention, but my earlier tests showed me that the cart_order session variable only gets cleared sometime after the review order form page HTML is generated. That narrows it down a bit further.

I've now ruled out the shopping cart block as being the hook responsible.

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

The logs say it all:

Checkout page:

127.0.0.1 - - [15/May/2008:17:27:00 +0100] "POST /cart HTTP/1.1" 302 -
127.0.0.1 - - [15/May/2008:17:27:01 +0100] "GET /cart/checkout HTTP/1.1" 200 25229
127.0.0.1 - - [15/May/2008:17:27:02 +0100] "GET /modules/system/system.css HTTP/1.1" 200 6932
127.0.0.1 - - [15/May/2008:17:27:02 +0100] "GET /misc/jquery.js HTTP/1.1" 200 19340
127.0.0.1 - - [15/May/2008:17:27:03 +0100] "POST /cart/checkout/payment_details/contact HTTP/1.1" 200 58
127.0.0.1 - - [15/May/2008:17:27:02 +0100] "GET /cart/files/images/woodcutborder1.jpg HTTP/1.1" 200 8877
127.0.0.1 - - [15/May/2008:17:27:03 +0100] "POST /cart/checkout/line_items HTTP/1.1" 200 230

Review page (note extra GET request at the end which clears the session variable):

127.0.0.1 - - [15/May/2008:17:27:25 +0100] "POST /cart/checkout HTTP/1.1" 302 -
127.0.0.1 - - [15/May/2008:17:27:26 +0100] "GET /cart/checkout/review HTTP/1.1" 200 9607
127.0.0.1 - - [15/May/2008:17:27:26 +0100] "GET /modules/system/system.css HTTP/1.1" 200 6932
127.0.0.1 - - [15/May/2008:17:27:26 +0100] "GET /misc/jquery.js HTTP/1.1" 200 19340
127.0.0.1 - - [15/May/2008:17:27:27 +0100] "GET /cart/checkout/files/images/woodcutborder1.jpg HTTP/1.1" 200 25241

Order complete page:

127.0.0.1 - - [15/May/2008:17:27:41 +0100] "POST /cart/checkout/review HTTP/1.1" 302 -
127.0.0.1 - - [15/May/2008:17:27:42 +0100] "GET /cart/checkout/complete HTTP/1.1" 200 7791
127.0.0.1 - - [15/May/2008:17:27:43 +0100] "GET /modules/system/system.css HTTP/1.1" 200 6932
127.0.0.1 - - [15/May/2008:17:27:43 +0100] "GET /misc/jquery.js HTTP/1.1" 200 19340
127.0.0.1 - - [15/May/2008:17:27:43 +0100] "GET /cart/checkout/files/images/woodcutborder1.jpg HTTP/1.1" 302 -
127.0.0.1 - - [15/May/2008:17:27:44 +0100] "GET /cart HTTP/1.1" 200 7150

So the client browser is loading the image with path relative to /cart/checkout and not relative to Drupal root, which Ubercart apparently redirects internally to /cart (hence the HTTP 200 response code) which calls the function that clears the session variable. Note that in the log for the order complete page, Drupal issues a 302 redirect.

So, should we not be getting a 404 for any requests below /cart that don't exist as functions or files, like Drupal does normally, such that a request for /admin/fakename will give a 404?

Posts: 5367
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Hmm... I'm not really sure how such an idea would be possible right now. It can be developed in a contrib if someone has any ideas and we can consider rolling it into core later. It's just that there's a lot of /cart/xxx URLs and they're certainly not all cached. Gotta think about the AJAX requests helping building the checkout form.

I guess mostly I'd just say to use absolute URLs in your HTML or at the very least prefix them with a / so they're relative to the root and not the current page. You'd have to do this for that image to display on any other page than the front page as well. I'm glad you got it figured out. Smiling

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

Yes, it's rather a liminal sort of issue, and as you point out it only arises when a user puts in a relative URL somewhere else on the page. I don't know Drupal very well at all, so I don't know where Ubercart binds to all these sub-URLs. If you could point me to where this happens then I might be able to think about methods of dealing with it.

Posts: 5367
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

It all happens through Drupal's menu system... any module with a function whose name ends in _menu adds items to the menu array. Drupal goes off of a cached and a non-cached menu register, although it will change in Drupal 6. I'm just not sure there's a method of adding the page-not-found redirect that would be easier to implement than building the HTML to be more specific.

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

Ah, I was aware of the menu callbacks but thought it didn't do a "greedy" match. So basically any call for "/cart/.*" will call uc_cart_view() and reset the cart unless there's already a match from the menu system (e.g., "cart/checkout").

I remember now (from the Pro Drupal Development book) that extra URL arguments are passed into the function, so in this case there's a simple method for checking whether we ought to destroy the checkout status: see if the number of function arguments exceeds the number of arguments in the function declaration. If so, there is an overloaded URL which might indicate a bad user request that should be discarded with a 404. So my suggestion to solve the current problem in uc_cart.module line 1267:

function uc_cart_view_form_submit($form_id, $form_values) {

if ((func_num_args()>2)) {
  return drupal_not_found();
}

...
}

You might want to use this sort of code in other functions, if there's a chance of something similar happening (which there probably is, esp in other functions in uc_cart.module).

By the way, I noticed you use HTTP Referrers a lot in uc_cart.module. Are you aware that the referrer is sent by the client and thus -- like all user input -- it can be forged (e.g., with the RefControl FF extension) and that often referrers are blocked for privacy reasons (e.g., by antivirus software)? This is important because there's a security check (line 1356) that checks the referrer and clears the cart_order variable if it is absent, which makes checkout impossible for anyone who blocks the referrer -- potentially a much more widespread problem than the one I originally reported (actually I'm a bit bemused that this problem hasn't been mentioned before). I think you'll have to use $_SESSION to store the previous page -- if necessary -- rather than use the HTTP_REFERER value. HTTP_REFERER is really only useful for stats.

I would be happy to work on this one & offer my changes to the Cart module, but I don't see how any of this could be done in a contrib.

Posts: 5367
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Aye, I've known about the weakness of the referrer stuff, but hadn't had the chance to get back to it. I wasn't aware of an extension that would just break the process for folks, though. It's mostly there as just another deterrent for hopping around to URLs you shouldn't be at, but I don't think it presents a security risk at the minute. If you want to work up a patch, I'd be happy to review it, but I may hold off on it until after the 1.0 release.

I'm not sure what would be a foolproof better method to replace the referer. I mean, you could use a session variable that gets set when a form is in validation and removed when the checkout form loads... but then if someone were to browse away during checkout, someone else on their computer could come back to the middle of checkout w/ that session variable still set. At best, if this fails, someone will just find out what you were going to buy and your address info if you went to review and then came back to checkout for some reason.

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

Yes, it's not a security risk at all, but rather a usability problem. I know ZoneAlarm has an option to block the referrer, and apparently so does Norton, as does Opera in the "Quick Preferences" menu; but perhaps more significantly corporate firewalls and caching proxies effectively block referrers, so we're probably talking about a significant number of users -- especially the larger corporates, institutions and government offices, some of whom wouldn't be able to get any orders past checkout. This is especially problematic because the order completed screen would be shown to the customer. It's a show-stopper for me.

My suggested solution is twofold:

1) Set a session variables that records the page just viewed in hook_exit() (which executes even on cached pages). Obviously it won't be useful if a user browses to a different website and comes back, but for that we can still check the referer as well, just allowing that it might be a null string. In fact, the Review Order page posts the address info, and a potential hijacker could use the Back button, so I really don't think this much security anyway. (Other modules -- Product Kit and Recurring Payments -- also currently use HTTP_REFERER, so this will benefit them too.)

2) Set a timed session variable at checkout that will clear the cart_order variable after 15 minutes. This is as good in terms of security as it can possibly get for this particular problem.

I have implemented (1) in the attached files, based on the current Bazaar files. I had to put the referrer session variable in uc_store.module because it's used by modules other than Cart. I've patched those other modules -- Product Kit and Recurring Payments -- to use the new session variable rather than HTTP_REFERER. Thus, in addition to allowing privacy-sensitive users to use the checkout, we should now have 100% accurate redirects from add-to-cart links.

I've also added a simple check to prevent the order complete page being generated even on null orders in uc_cart_checkout_review_form_submit(). Previously it would show an order complete page with just blank variables (which might confuse users into thinking they had been charged twice), now it unsets cart_order and redirects to /cart/checkout with an error message. It also tests that the user has arrived from cart/checkout/review.

In doing all this, I haven't tampered with the $_SESSION['last_url'] variable, which has a slightly different purpose. It could be subsumed into the new variable, I suppose; but it's hardly essential. Also, in the process of making this patch, I noticed what appears to be an invalid reference to a $referer variable in the Catalog module which you might want to look at.

I haven't implemented (2) because I think to do it elegantly it would require a new "menu" entry (=page) for when a session times out, and also a configuration setting to go with it, so it's obviously more than just a simple patch.

In addition to implementing (1), I've added the func_num_args() patch mentioned in my previous post to solve the problem I originally reported re: images with relative URLs in side-blocks. I think this will be made irrelevant by Drupal 6.

Let me know what you think. It could do with further testing, but I really hope this can make it into 1.0.

AttachmentSize
referer_patched_files.zip50.9 KB
Posts: 5367
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Thanks for all your work on this. I think something like this solution has been needed for a while, as it will address the "Continue shopping" link suggestions that have popped up in the past as well as this issue related to the review order page. Is there any chance I could get you to make a patch out of this instead of uploading the files themselves? Bazaar has some way to create patch files, though the command escapes me at the moment.

Posts: 2267
Joined: 08/07/2007
AdministratoreLiTe!

bzr diff

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

I didn't think of that but I suppose it would enable a "Continue Shopping" link. Cool!

Currently, my edits don't address the issue re: refreshing the Review Order page, but I'll look into that and see if I can address that at the same time.

If you're happy with this, I'll add the timed session thing too.

I'll provide a diff in due course, assuming I can figure out how to use Bazaar. There are some other things I'm working on, but I'll hopefully be able to bring it all for you some time tomorrow.

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

I've attached the patches I mentioned and the timed session thing.

The tests are roughly as follows:
cart/checkout -- can arrive from anywhere, but any data is voided if the referer is not cart/checkout or cart/checkout/review
cart/checkout/review -- must arrive from cart/checkout or cart/checkout/review
cart/checkout/review submit -- must arrive from cart/checkout/review

If at any time the checkout session times out, the data is voided and an error message is set. There is an admin checkout setting to set the timeout value (default 15 minutes).

The helper functions I've created are:
uc_cart_checkout_timeout() -- in uc_cart.module
uc_referer_check() -- in uc_store.module, because that's where the session variable is yet

Note that the Review order page will allow a refresh, but won't refresh properly when using uc_credit.module because the credit card data disappears. I haven't looked into that module yet, but I note that when the "(Last 4)" thing comes up it can't reconstruct the full number again. It otherwise behaves a little unpredictably, so whilst you're reviewing the attached diff I'll look into the credit card module as there are a number of things I'd like to think about & perhaps prepare changes for, including the following:

  • Add StartDate && IssueNumber
  • Visa can issue cards for up to 20 years
  • must have master database of accepted cards with ID numbers that can be accurately identified by payment gateway modules (to replace the
  • user-defined select list which needs to be regexed in a payment gateway). Then can also displays additional credit card images at checkout.
  • Credit card number should have basic validation -- is_numeric -- even if full validation is switched off
  • Add some validation for other card types

I'll leave the view cart "continue shopping" thing for now, but it should a piece of cake now.

BTW I'm writing a payment gateway that will integrate 3D-Secure authentication somehow, and I was wondering if any of you guys had come across an implementation of this for Ubercart. It seems like it'll probably end up having to be quite AJAXy.

AttachmentSize
patches.diff9.23 KB
Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

Oh dear, looks like I sloppily introduced some bugs with some last-minute tinkering to those patches. Oddly enough it seems to be the same thing that was causing problems displaying credit card and address data on a back-to-checkout page in RC5 and before, which might -- perhaps -- now be fixed. Have attached new version.

line 1355 in uc_cart.module::

if (!($order = uc_order_load($_SESSION['cart_order'])) [...]

becomes
$order = uc_order_load($_SESSION['cart_order']);
[...]
    if ($order === FALSE ( [...]

AttachmentSize
uberpatches.diff9.31 KB
Posts: 5367
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Haven't had a chance to test this yet, but it's bookmarked and I'll hopefully get to review it today.

Posts: 2267
Joined: 08/07/2007
AdministratoreLiTe!

It's no good. From cart/checkout, I can type in "/review" to the end of the URL and completely bypass the checkout validation. On the upside, it seems it didn't actually create an order, even though I clicked through to cart/checkout/complete like normal.

Before, doing this just sends me back to the cart page.

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

Thanks Lyle, something of an oversight there -- too permissive in allowing cart/checkout referer without the do_review session variable. Have attached updated patch to combat this menace.

Did you notice anything else wrong, or is this it?

As an aside, I'm inclined to think there should be a message of some kind when users are redirected back to cart/checkout.

AttachmentSize
patch3.diff9.3 KB
Posts: 2267
Joined: 08/07/2007
AdministratoreLiTe!

Well, trying to use Cygwin to patch my installation kind of screwed up my file permissions. I'll figure out something else and see what happens.

Posts: 2267
Joined: 08/07/2007
AdministratoreLiTe!

Patched my installation manually this time, and I think it works pretty well. I did clean it up a little (mostly spacing issues) and since drupal_goto() calls exit(), you don't need return after it.

I got the timeout message when I refreshed the checkout page after the patch, but I think that's just a fluke. Most people won't start from there after other sites are updated.

Even still, I'm not the best tester in the world, and I'd appreciate more people trying this out. It's in the Bazaar version now, so problems should show up pretty quickly.

Posts: 23
Joined: 05/19/2008
Bug Finder

wrong test condition for uc_referer_check in uc_cart_form_alter ..

function uc_cart_form_alter($form_id, &$form) {
  // Redirect shopper back to checkout page if they go to login from there.
  if ($form_id == 'user_login' || $form_id == 'user_edit' || $form_id == 'user_register') {
    if ($_SESSION['checkout-redirect'] == TRUE) {
      $form['#action'] = url($_GET['q'], "destination=cart/checkout");
      return;
    }

    if (!uc_referer_check('cart/checkout')) {
      $form['#action'] = url($_GET['q'], "destination=cart/checkout");
    }
    elseif (!uc_referer_check('cart/checkout/complete')) {
      $form['#action'] = url($_GET['q'], "destination=user");
    }
  }
}

should be ...

function uc_cart_form_alter($form_id, &$form) {
  // Redirect shopper back to checkout page if they go to login from there.
  if ($form_id == 'user_login' || $form_id == 'user_edit' || $form_id == 'user_register') {
    if ($_SESSION['checkout-redirect'] == TRUE) {
      $form['#action'] = url($_GET['q'], "destination=cart/checkout");
      return;
    }

    if (uc_referer_check('cart/checkout')) {
      $form['#action'] = url($_GET['q'], "destination=cart/checkout");
    }
    elseif (uc_referer_check('cart/checkout/complete')) {
      $form['#action'] = url($_GET['q'], "destination=user");
    }
  }
}

The test will always be true UNTIL you are on the designated page. And every time you log in you are redirected to the shopping cart.

Katrina

www.ambereyes.net

Posts: 2267
Joined: 08/07/2007
AdministratoreLiTe!

Good catch. Enjoy your badge.

Posts: 5367
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Well... now that this patch has been committed, I just came up with a possible reason for it not to be. Smiling Multiple tabs. So... I might have the checkout page open and be filling it out and need to verify some product info. In another tab, I browse to the product page, and it resets my last visited page. Now when I try to proceed through checkout, I'm going to kick up errors.

I think this happened to me when testing out whether this was a good solution for the Cancel links in the recurring module. There I also found that refreshing the page causes the cancel links to refer to the same page instead of the previous one... so it's almost like we should be storing the last two pages to account for refreshes somehow. Seems like the old referer_uri() actually accounts for page refreshes correctly (but not page reloads).

Anyways, I consider both of these deal breakers... the patch addressed the original problem but created two others. I'm not saying we should remove it wholesale, but I don't have time to work on the solution right now. If we can fix it before tomorrow, that'd be great. Otherwise, I wouldn't have a problem putting a fix like this into a 1.1 release.

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

If necessary we can reduce the testing to just prevent offsite HTTP_REFERERs and not use the session variable in that function.

However, the referrer session variable will still be useful for a "Continue shopping" link in the cart page.

Posts: 5367
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Agreed... one thought I had was to leave the core function in there but revert areas of use to the referer_uri() until we could sort out the uc_check_referer() function. I think making uc_store_exit() track the last couple of hits would help prevent something like a user updating their shopping cart so that the continue shopping link just points them to the shopping cart page.

I'm still fully supporting this patch's functionality, btw. Just gotta sort out these implementation issues. Cool

(It might be helpful to split some of the features out into separate issues, too.)

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

Well, if I'm brutally honest for a second, I don't see much value in this referer check anyway (except for the continue shopping link). The real problem is storing cc numbers in session variables, which often get stored on servers for long periods of time in world-writable /tmp directories, thus completely obviating your other work on PCI DSS. This does actually change the status of Ubercart for PCI DSS purposes... cc numbers should only ever be kept in POST.

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

P.S. Yes, I appreciate that there is now an encryption key for these cc numbers, but this only offers protection against a small subsection of attack vectors (leaking the session of an order which is in checkout). I've posted elsewhere on this. I think what I've proposed would actually remove any advantage in checking for referers in cart/checkout and cart/checkout review at all. Addresses are stored in user sessions anyway, so anyone who leaves themselves logged in is vulnerable to that and it's not something a referrer check can possibly solve; but cc numbers would be totally invulnerable.

Re: the page refresh problem, yes I agree we should store the last 2 unique locations to help with that.

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

I see the new function has now been removed from bazaar, thus restoring the silent requirement to have client referers. Ryan, do you have a diff for this against v1.0, so I can restore it in my own version? I would like to resolve these issues you raise so it can go back in again. I feel it's fairly essential for basic functionality.

I see my func_num_args hack got removed too...

Posts: 5367
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Aye, I was running way short on time and ended up having to revert most of the patch in order to put out the 1.0 release. I just didn't have time to do full testing, and as it turns out I don't think Lyle knew about the func_num_args thing to do good testing on it before committing.

In Bazaar, you can easily do a diff between two revisions. Example:

bzr diff -r1045..1046

Can you split the features out into separate patches for the future so we can make sure they all get tested? Also, I'd like to figure out how to move more of the hard core patching/testing out of the forums and into the issue tracker on d.o. If you have any thoughts on how to handle that, feel free to let me know.

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

OK, I'll post my various patches on drupal.org. I do want to get them "out of the way", though, then hopefully I can move on to stuff like VAT (as I'm based in the UK and currently work part-time as the book-keeper for a Limited Company).

Re: moving some stuff to the drupal.org issue tracker, I'm afraid I really don't have any ideas. It already seems quite complex, what with the forums & issue tracker here, as well as the support.ubercart.org.

Posts: 1314
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

The goal I think, from what I've read, is to eventually stop taking issues here, but continue using the Ubercart.org forums for development ideas and brainstorming, etc. But the official Contribs should be moved over to Drupal.org. (I just haven't gotten around to doing mine yet...)

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

On second thoughts I think it would be rather silly to move this current discussion over to d.o just yet. We need to be clear about how to approach this, and we need some consensus before I prepare a patch.

Firstly, there seems to be only a very weak case for wanting to check where the user has come from when they are at cart/checkout/review. The rationale seems to be that a shopper might leave their computer for another person to examine, and we therefore need to be careful about displaying checkout information. I don't think this is a danger, given that it all happens within a session; but whatever we do, we will probably always be defeated by the "Back" button. Are we not just wasting time with this?

Secondly, my view is that assuming HTTP_REFERER exists and is valid is bad, bad, bad. I don't know what the percentage of users without HTTP_REFERER is, but I don't think it's for Ubercart to arbitrarily exclude certain shoppers without providing a reason. At present, there is not even an error message. Therefore, whatever the answer to the first point, the current situation is untenable.

Thirdly, I think the referer check issue is being conflated with totally different issues relating to user redirects. Forms that need to redirect users should have the referring page passed to them directly, rather than seeking to guess it from referers or the like.

Thoughts?

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

I've added a patch that combines the best of both worlds here.

Posts: 130
Joined: 08/07/2007

solarian...does this patch work for the 'incheckout' problem? I just started having it when i switched themes.

Posts: 5
Joined: 06/29/2008

The URI referrer check code in uc_cart_checkout_form() (in Ubercart 1.0) leads to nasty bugs. I just spent a couple hours tracking this one down - very hard to make a leap from order data being lost during checkout (the "Your order number is ." bug) to a template file being improperly referenced (so as to load the /cart function).

I have not had the opportunity to test the patches above, but I encourage the UC team to consider accepting one of them. For now I'm just commenting out the unset() line - I'm not confident the client won't accidentally introduce a bad URL reference (say, an image in a block that is src="images/blah/blah" instead of src="/images/blah/blah") and give me hell for the cart not working as a result.

Posts: 5367
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

If you've tried and tested the patches, that'd be great. I honestly just haven't had time to review them since they were posted. Sad I hope to get to them this week so we can put up a 1.1 release, but I wouldn't hold your breath...

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

mimetic2 -- not sure whether this fixes that problem, unless it's the one I refer to at the beginning of this thread.

greenmachine -- the patch you're looking for has actually been separated out:
http://drupal.org/node/270781

You just need to put
if ((func_num_args() > 0)) { return drupal_not_found(); }
at the start of uc_cart_view().

Ryan -- I can't say it's had proper testing from me. There is, however, not terribly much to go wrong I think, because the patch is quite unintrusive.

Posts: 130
Joined: 08/07/2007

Solarian -

My problme was that all of my orders were going to incheckout (and not checkout).

For some reason my $base_path function didnt work so i had to use Global[Base_path], which i think fixed the problem.

However if i d/led you're patch, would this remove any future similiar errors like that from happening in the future?

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

The honest answer is: I really don't know. I think the func_num_args() patch *might* fix it, but you should never need that patch on a properly configured system. It's just that people (like me) don't always have things configured right.

Posts: 20
Joined: 05/14/2008
Bug Finder

I just upgraded to 1.2 and the uc_referer_check() broke checkouts for me (and others as discussed elsewhere). In my case the fix is not as simple as detecting https, because I was also doing some url rewriting to remove the 'cart' portion of the address.

Can you pull this function or make it optional?

Posts: 5367
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Out of curiosity... how were you passing before w/ the URL rewriting? I have indeed found a couple of bugs now in the patch, but the functionality it's replacing was there before and based on the URL.

Posts: 20
Joined: 05/14/2008
Bug Finder

I'm using custom_url_rewrite() to map /checkout/* to /cart/checkout/* on incoming urls and vice versa for outgoing urls. I'm not sure if that explains it for you or not?

I found a way to work around this without modifying any uc code. My solution is to use hook_init to clear the referrer environment variables whenever the request_uri matches 'checkout'. That way, the referer check always returns true. So long as this continues to work, I'm happy. I would hate to have to modify uc code.

Posts: 56
Joined: 04/20/2008
Bug FinderGetting busy with the Ubercode.

Not sure what variable(s) you're clearing, but I think you could probably just clear $_SERVER['HTTP_REFERER'] in hook_init() and leave the $_SESSION['last_url'] alone, and it should still work.

Posts: 2
Joined: 08/02/2008

Sorry to be repetitive but I am in NOOO WAY a pro programmer like you guys (infact I don't consider myself a programmer at all), but I am having a big headache from hitting the "Review Order" button. From what I can tell all my setting for ubercart and shipping quotes are coming out fine.

When I hit the "Review Order" Button, the next page never loads and eventually the browser times out. I am running GoDaddy hosting with a current upgrade to PHP Version 5.x from PHP version 4.x (after installing and configuring Ubercart)

Your time and help is much appreciated, I have been looking both on Ubercart and Drupal forum for at least 8 hrs straight, but nothing has fixed my problem.

I am using Ubercart 5.x-1.3 & I am running on Drupal 5.9.

Thank you again

Posts: 2
Joined: 08/02/2008

YEEAAAAA...I finally got it to work. Well it seems there was nothing wrong with the version of Drupal or Ubercart I was running. It was my checkout payment options that caused the problem.

For some reason, choosing "Paypal Express Checkout" wasn't working so I just changed to "PayPal Website Payments Standards". You can find this setting under http://www.yoursite.com/admin/store/settings/payment/edit/methods

Hope this helps Smiling