Closed (fixed)
Project:
Ubercart
Version:
7.x-3.x-dev
Component:
Orders
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
4 Oct 2011 at 00:10 UTC
Updated:
28 Sep 2012 at 16:11 UTC
Jump to comment: Most recent file
Comments
Comment #1
wodenx commentedPatch attached.
Comment #2
longwaveIf $order is FALSE for some reason, trying to update its status will result in an error.
I also don't think we should touch the order status if it's not in_checkout for some reason, or if the uid changes. Perhaps the customer called in to complete the order, and the admin manually changed the status while it's still in the customer's session.
Comment #3
wodenx commentedGood point about the order status. Not sure I understand about the uid - when would an admin change the uid of an order and leave it in checkout? I think as long as the order has timed-out while it's status is in_checkout, it should be marked as abandoned.
Comment #4
longwaveI am not really sure what that uid check is meant to achieve in the first place, or what would trigger it to fail.
Comment #6
tr commentedPatch failure is "Cannot redeclare uc_order_update_7004()"
This is because there's already a uc_order_update_7004() defined in uc_order.install. The hook_update_N() added by the patch needs to be renamed uc_order_update_7005().
@wodenx: Can you post an updated patch?
Comment #7
wodenx commentedLooks like that was introduced by commit #1645d08e8d293b335e35cbe8600ed90f00582fd4, right around the time I submitted the last patch. Anyway, here's revised version.
Comment #8
wodenx commentedComment #9
wodenx commentedUpdated to apply to current HEAD. Giving this a bump bc it would be helpful for #649306: Make coupon usage counting more flexible
Comment #10
longwaveShouldn't that be $order->order_status? Let's also get that "600" moved to a constant rather than using magic numbers.
Would be nice to get a test added for this, it would have to update $order->modified manually to avoid the test having to wait ten minutes, but otherwise should be fairly easy to write.
Comment #11
wodenx commentedIncorporated suggestions from #10.
Comment #12
longwaveThis looks good and works well in testing.
I wonder if we should have a hook_update_N() to do the initial update here, setting the order_status directly; on sites with many "in checkout" orders (perhaps upgrades from D6) the first cron run might take a long time.
Comment #13
tr commented@wodenx: Thanks for adding the tests - that more than anything helps me see how this is supposed to work and convinces me that it works properly.
I agree with @longwave in #12 that the initial update of the status should be done as a batch in a hook_update_N() rather than leaving it to the first run of hook_cron(). Otherwise, I think this is ready to go in.
Comment #14
longwaveAs this is a new status, nothing should be expecting to react on it, so I think we can safely abandon old orders in a single query.
Comment #15
tr commentedTested and works for me on a site which had ~500 In Checkout orders. Update successfully moved all In Checkout to Abandoned. New In Checkout orders were moved to Abandoned via cron after 10 minutes.
Comment #16
wodenx commentedHa - I was just testing it - works well here, too. My only thought was, should we move the definition of the timeout into uc_order so we don't have to hardcode the number in the update hook (see attached patch).
Comment #18
longwave.module files are not guaranteed to be available during hook_update_N() unless loaded explicitly, which is why I hardcoded the constant. I think the timeout should belong to uc_cart rather than uc_order; the "in checkout" and "abandoned" statuses should probably technically be owned by uc_cart as well, but it's not worth fixing that now.
Back to RTBC for #14, will commit later.
Comment #19
wodenx commentedOh, I see - if update is run when the module is disabled. I guess that makes sense - you want the update_N to work even if that constant is removed in the future.
Comment #20
longwaveCommitted #14.
Comment #22
tmsimont commentedHey not sure if I should re-open or open my own issue, but it looks like something was missed in all of this:
#10:
It looks like 600 is still hard coded into uc_cart.pages.inc in the latest branch.
Patch attached
Comment #23
Dan Z commentedSee #18 and #19. Test your patch with the relevant modules disabled and see if it still works.
Comment #24
tmsimont commentedI disabled uc_cart -- ran update.php, no problems
I disabled uc_order -- ran update.php, no problems
Comment #25
tmsimont commentedalthough i didn't have any updates to perform.. does that matter?
Comment #26
longwaveCommitted, thanks. This is valid; the only place the constant should not be used is in the update hook in uc_order.install.