Finally got around to installing/using ubercart, and found the error log littered with warnings.

The attached patch is my first-pass attempt at eliminating the worst offenders.

Comments

Island Usurper’s picture

Status: Needs review » Needs work

We're not planning on porting uc_importer or uc_notify, so there's no need to include their files in this patch.

As a matter of consistency, I usually prefer isset() to empty(). This is partly because there are times when the data that is checked has a value of 0 or '', and that's the value that should be used rather than the default used when it is NULL. I think the only place this is actually important in this patch is in uc_product_form(), for $node->default_qty. The default value is 1, but a value of 0 is never displayed in the form, despite the fact that it is a valid value.

pillarsdotnet’s picture

StatusFileSize
new10.47 KB

@Island Usurper:

We're not planning on porting uc_importer or uc_notify, so there's no need to include their files in this patch.

(checking...) Hmm... must have been working from old code (??) Patch revised.

As a matter of consistency, I usually prefer isset() to empty().

You are correct; I have grown over-fond of empty() because my most frequent use is to replace:

if ($undefined_or_nonzero_variable)

with

if (!empty($undefined_or_nonzero_variable))

Revised patch attached; created via "cvs diff" from today's DRUPAL-6--2 checkout.

pillarsdotnet’s picture

Status: Needs work » Needs review

Changed status

cha0s’s picture

StatusFileSize
new8.72 KB

I cleaned up a couple of small things, just aesthetics.

pillarsdotnet’s picture

StatusFileSize
new27.39 KB

Applied suggested changes, plus more fixes. Notably, disabling fields actually causes them to disappear from the display, now. (yay!)

note: patch looks big because wrapping some code in if() blocks changes indentation.

cha0s’s picture

Nice, but for ease of comprehension's sake, you should separate the views changes from the undefined variable changes. Put the overlapping changes into the views patch (i.e. if a variable has been created by your view patch, and you do an isset check, put it in the views patch)

One small thing too, in uc_store.module, do the if like this:

if (foo) {
}
else {
}

not like this:

if (foo) {
} else {
}

Just a consistency thing :). Thank you for your contribution(s)!

Island Usurper’s picture

Status: Needs review » Needs work
cha0s’s picture

Assigned: Unassigned » cha0s
Status: Needs work » Needs review
StatusFileSize
new17.28 KB

Patch for views: #367730: Views fixes

Attached the patch for variable cleanup.

Island Usurper’s picture

Status: Needs review » Needs work

I'm a little worried about the use of the static keyword in uc_product_field_enabled(). I imagine that something like SimpleTest would change the value of the variable, and then call that function again and get the wrong values. Variables are all cached anyway, so I don't think it's necessary to do it again.

There are at least 3 solutions that I can think of, but I think the best one is the easiest, which is just remove the static keyword. The rest of the function can stay the same, and so can its use in this patch.

cha0s’s picture

Status: Needs work » Needs review
StatusFileSize
new17.01 KB

As you have requested...

Island Usurper’s picture

Status: Needs review » Fixed

Wow. Committed this, but almost forgot to mark it fixed.

acsooley’s picture

Would this patch fix:

When I try to create a view for the main page to display a image of the product, price and add to cart button I get an error on adding the image to the view:

Error: handler for node_data_field_image_cache > field_image_cache_fid doesn't exist!

All other fields work and display on the view except for the image. Any help would be great.

Adam

Status: Fixed » Closed (fixed)

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