Remove php notices

solotandem - January 21, 2009 - 17:45
Project:Ubercart Addresses
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:freixas
Status:closed
Description

Please apply this diff (or something similar) to remove a bunch of php notices that display.

AttachmentSize
uc_addresses_address_pane.inc_.diff1.37 KB

#1

freixas - January 22, 2009 - 15:54

Thank you for taking the time to create a patch.

I added a correction for the missing initialization of $output in theme_uc_addresses_pane().

I want to understand the other fix a little better. In uc_addresses_pane_address, it seems that if $arg1 is null that $arg1->first_name should generate an error, not a notice. Also, creating an empty address seems like the wrong solution. I'd rather try to find out why $arg1 is coming in as null.

Can you tell me how to reproduce this situtation?

Thanks.

#2

solotandem - January 22, 2009 - 16:52

The notices display when I try to add a new address for a user. (I have E_ALL set in common.inc.)

Could you simply use empty strings for all these fields instead of referring to $arg1 as this is in the case of 'new' or 'add' so these fields should not have any values, right?

#3

freixas - January 22, 2009 - 21:48
Assigned to:Anonymous» freixas

'new' or 'add' should definitely have values, even if the values are all empty strings.

If you set up for addresses so that they are required during registration, then 'new' gets called and it should have an address. When you go to your profile and add a new address, 'add' gets called. Elsewhere, you set which address fields are required and which are optional, but the address object is not optional.

When I get a moment, I'll try to reproduce this. In the meantime, could you tell me how you configured the address options in the store configuration section? Is there anything else special about your system?

Also, you say you get these notices when you add a new address for a user. Does the address actually get stored? If it does, then who is calling the method with $arg1 set to null? Since you sound like a programmer, a debug_print_backtrace() might reveal something interesting.

There is some AJAX magic that happens if you change the country. It could be that the AJAX call winds up calling my method with $arg1 set to null and then I get a later call when the address is really added.

Again, I'll take a look when I have a chance, but since you have a system where you know you can reproduce the problem, it would be useful to look at your backtrace.

Thanks for the help.

#4

solotandem - January 23, 2009 - 16:58

As requested, I have attached two files of output when clicking on add address from the user profile pages.

1) php notices
2) back trace

Thanks for looking into this.

AttachmentSize
add_notices.txt 3.22 KB
add_trace.txt 25.95 KB

#5

freixas - February 1, 2009 - 06:48
Status:needs review» fixed

Sorry to take so long to get back to you.

First of all, thanks for letting me know about the trick of setting E_ALL in common.inc. In the process, I not only saw the problem you reported, but a lot of other problems as I executed the various functions in my module.

Your initial analysis and diff was pretty much right on. I adopted your solution for creating a blank address for the initial presentation of a new or add form.

All the fixes I added have been checked in and will appear in the first dev release dated 1/31/09 or later.

#6

System Message - February 15, 2009 - 06:50
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.