Closed (fixed)
Project:
Ubercart
Version:
6.x-2.x-dev
Component:
Products
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
2 Nov 2010 at 11:46 UTC
Updated:
7 Jun 2011 at 05:11 UTC
Jump to comment: Most recent file
function uc_catalog_buy_it_now_form_validate($form, &$form_state) {
if (module_exists('uc_attribute')) {
$node = node_load($form_state['values']['nid']); //not needed at all!
$attributes = uc_product_get_attributes($node->nid); //nid is already in $form_state
if (!empty($attributes)) {
drupal_set_message(t('This product has options that need to be selected before purchase. Please select them in the form below.'), 'error');
drupal_goto('node/'. $form_state['values']['nid']);
}
}
}
I've also notice there are lot of using node_load() in such simple tasks for example uc_product_is_product with 'nid' as an argument does that huge task just to check single type field. This can be done much faster, for example we can check if the following query is not empty - 'select nid from uc_products where nid='
Ubercart can be much faster...
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 959840.patch | 793 bytes | tr |
Comments
Comment #1
sleamey commentedComment #2
sleamey commentedComment #3
tr commentedI've investigated this situation and I think there should be no consequences to removing the node_load(). The Ubercart test cases all still pass with this change. Test coverage isn't fantastic, so that's not sufficient, but at least it's a start.
Patch attached. I'd like to see some reviews before this goes in to make sure there aren't any unintended side-effects.
Same patch is needed for Ubercart 7.x-3.x ...
Comment #4
tr commented(ignore the .ods - attached by accident.)
Comment #5
longwaveSeems reasonable, and I can't see why it would have side effects. Ideally this code should be moved into uc_attribute as well, there should be no reason to have module_exists() calls here.
Comment #6
tr commentedCommitted to 6.x-2.x-dev and 7.x-3.x-dev.