When I'm at cart/checkout page, all required fields filled, and click send, I get a blank page with this message:

Fatal error: Uncaught exception 'UcAddressesInvalidFieldException' with message 'Invalid field name ' in /*/sites/all/modules/uc_addresses/class/UcAddressesSchemaAddress.class.php:244 Stack trace: #0 /*/sites/all/modules/uc_addresses/class/UcAddressesSchemaAddress.class.php(187): UcAddressesSchemaAddress::fieldMustExist(NULL) #1 /*/sites/all/modules/uc_addresses/class/UcAddressesAddress.class.php(263): UcAddressesSchemaAddress->setField(NULL, '') #2 /*/sites/all/modules/uc_extra_fields_pane/uc_extra_fields_pane.module(495): UcAddressesAddress->setField(NULL, '') #3 /*/sites/all/modules/ubercart/uc_order/uc_order.module(1474): uc_extra_fields_pane_order('load', Object(stdClass), NULL) #4 /*/sites/all/modules/ubercart/uc_order/uc_order.module(1199): uc_order_module_invoke('load', Objec in /*/sites/all/modules/uc_addresses/class/UcAddressesSchemaAddress.class.php on line 244

Thenafter when I refresh the page it's confirms the order as normal. What can possibly render this error message??

I have those modules installed:
Ubercart 6.x-2.9
Ubercart Addresses 6.x-2.x-dev (2012-05-18)
Ctools 6.x-1.8
Ubercart Extra Fields pane 6.x-2.0-beta2

Edit: It seems that adding "other addresses" (auto-created after an order was made?) than those two "default addresses" (bill and delivery) at the user/#/addresses page may cause this error? The auto-created "other addresses" conflict with the "default addresses"?

Comments

miccelito’s picture

Project: Ubercart Addresses » Extra Fields Checkout Pane
Issue summary: View changes

edit

miccelito’s picture

Issue summary: View changes

edit

megachriz’s picture

Project: Extra Fields Checkout Pane » Ubercart Addresses
Status: Active » Postponed (maintainer needs more info)

At first glance, it seems that it's caused by a bug in Extra Fields Pane. Extra Fields Pane tries to set an empty, non existing address field, which Ubercart Addresses doesn't allow. Although I have tested Extra Fields Pane together with Ubercart Addresses heavily, I didn't encountered this bug yet.

I'll need more information about how to reproduce this bug. Can you provide the exact steps you took that resulted into this error (configuration/setup, logged in as user ...)? I'm best helped if you'd be able to reproduce the bug in a fresh installation. Valuable things to know:

  • Do you have created any extra address fields with Extra Fields Pane? If yes, did they appear in the delivery checkout pane?
  • As which kind of user you did you got this error? Was it the superuser (user 1), an authenticated user or an anonymous user (I don't suspect it was an anonymous user, as that user usually doesn't have any addresses)?
  • How many addresses does the user have in it's address book? Is the default billing address equal to the default shipping address?
  • Do the addresses that were chosen at checkout have values for extra address fields?
  • Did you go to checkout review without any other errors (e.g. "Field x is a required field.")?
miccelito’s picture

Do you have created any extra address fields with Extra Fields Pane? If yes, did they appear in the delivery checkout pane?

I did add (admin/store/settings/addressfields/add) three extra address fields with Extra Fields Pane, two assigned to Billing pane and one assigned to Delivery pane, all three as fieldtype Textfield, none of the three checked as required. All three listed at admin/store/settings/checkout/edit/fields page. Besides those I have not added any Custom order fields.

As which kind of user you did you got this error? Was it the superuser (user 1), an authenticated user or an anonymous user (I don't suspect it was an anonymous user, as that user usually doesn't have any addresses)?

I did get the error both as user1 and as an authenticated user. Haven't tried as anonymous as I will not permit anonymous to send orders.

How many addresses does the user have in it's address book? Is the default billing address equal to the default shipping address?

I did add only two addreses for user1 and 2 addresses for the authenticated user (test account). The fields that appear in Default billing address (where I entered text in two of the three extra fields) also appear in Default shipping address (where I entered text in one of the three extra fields)

Do the addresses that were chosen at checkout have values for extra address fields?

Yes, using the values from current user's Address Book as default values.

Did you go to checkout review without any other errors (e.g. "Field x is a required field.")?

No "field x is required" or other errors.

But meanwhile I'm writing this reply I'm thinking that maybe the mentioned error occurs cause I'm using the module Optional Checkout Review (6.x-1.x-dev) - which enables the possibility to skip the "Order review" page meaning that when clicking the "Submit Order" button the order is sent - and I see now at extra address fields edit, that the checkbox for Order review page (page where the order is reviewed by a customer before the order is submitted) was enabled at all three extra adress fields, it should be disabled I guess.

Edit: I tried to disable the Order review page checkbox, no difference, the error remains. Further, after getting the mentioned error above if I refresh the page I sometimes get the message notification: "An illegal choice has been detected. Please contact the site administrator." as well that the Adress book select fields at cart/checkout page get red marked (.error)

Edit2: Thinking further, the error may occurs when certain fields at cart/checkout page are left empty and those fields are included in ubercart/uc_order/templates/tpl.php files' lines without if/else statements?

Edit3: As you said although you have tested Extra Fields Pane together with Ubercart Addresses heavily and didn't encountered this bug yet. Til now I have also tested heavily... disabled other uc modules to find out if there are any conflict, also tried to change some lines in uc_order templates etc, finally tracked it down to think that Extra Fields Pane/UC Addresses conflict with Optional Checkout Review module (skips the Order review page).
Would be great if you would try to install/enable the UC Optional Checkout Review module/enable skip the Order review page checkbox at checkout settings, to verify if that is causing the error.

megachriz’s picture

Thanks for reporting back, I'll try to setup a site like yours as far as I know how it is setup now, but I may not have time to do that this week. I haven't tested the modules in a setup with one delivery only field and two billing only fields yet. The tests I have done was with delivery/billing fields of each type plus one delivery only and one billing only field.

When I have time to test, I shall install the Optional Checkout Review module. Meanwhile, you could test if the error is still there when you (temporary) disable that module.

Have I understand well that you get the error every time you click the button "Review order" on the checkout page when you start with a "fresh" checkout? Or does it also happen in this case:
1. Go to checkout.
2. Don't fill in a required field.
3. Click "Review order" button.
4. Receive error message about the required field.
5. Fill in a required field.
6. Click "Review order" button.

But meanwhile I'm writing this reply I'm thinking that maybe the mentioned error occurs cause I'm using the module Optional Checkout Review (6.x-1.x-dev) - which enables the possibility to skip the "Order review" page meaning that when clicking the "Submit Order" button the order is sent - and I see now at extra address fields edit, that the checkbox for Order review page (page where the order is reviewed by a customer before the order is submitted) was enabled at all three extra adress fields, it should be disabled I guess.

The checkbox for the Order review page is a setting you can use if you want to display the field on the order review page. It doesn't matter if the order review page is visited or not, but when it's visited, the module checks which fields it should display. The field's display settings are unlikely to be involved in the error you get.

An illegal choice has been detected. Please contact the site administrator." as well that the Adress book select fields at cart/checkout page get red marked (.error)

That's interesting. I have seen this error once, early during the development of Ubercart Addresses 6.x-2.x (or was it the 7.x-1.x version?). I was not sure what caused that, but I hadn't seen it back again. It looks like you selected an address that changed between loading the checkout form and submitting the checkout form.

Edit2: Thinking further, the error may occurs when certain fields at cart/checkout page are left empty and those fields are included in ubercart/uc_order/templates/tpl.php files' lines without if/else statements?

I don't think the invoice template (which I think you are referring to) are involved with this error, unless you do some address manipulation there. Also, the invoice is send after the order is submitted. Maybe you can verify if the order exists after you submit the checkout form and get the UcAddressesInvalidFieldException error, but don't submit the checkout form again? Choose to view all orders, the order may have the 'in_checkout' status. If it exists, one thing that could happen when you open that order, is that you receive the same error. If it keeps doing that, it may be easier to track down the issue.

Edit3: As you said although you have tested Extra Fields Pane together with Ubercart Addresses heavily and didn't encountered this bug yet. Til now I have also tested heavily... disabled other uc modules to find out if there are any conflict, also tried to change some lines in uc_order templates etc, finally tracked it down to think that Extra Fields Pane/UC Addresses conflict with Optional Checkout Review module (skips the Order review page).

I have tested the modules in combination in a fresh installation, but not much in combination with other Ubercart contributed modules (only with Ubercart Views).

miccelito’s picture

Hello again, I appreciate your replies.

Regarding
Ubercart Addresses 6.x-2.0-alpha1+7-dev
Extra Fields Pane 6.x-2.0-beta2
vs
Optional Checkout Review 6.x-1.x-dev

When I have time to test, I shall install the Optional Checkout Review module. Meanwhile, you could test if the error is still there when you (temporary) disable that module.

Having the 'Skip checkout review' checkbox unchecked at Checkout settings, everything goes normal without no errors.

So I am pretty sure that the UC contributed module Optional Checkout Review (skip the Order review page) is causing the 'Uncaught exception UcAddressesInvalidFieldException' error. Since the mentioned error seems to happen only when having the 'Skip checkout review' checkbox enabled at Checkout settings. When this checkbox is unselected everything goes normal. I believe that it would be possible to solve the issue by adding some lines to either your UC Addresses module or to UC Optional Checkout Review module ('uc_optional_review_checkout.module' or/and 'uc_optional_review_checkout.js').

Have I understand well that you get the error every time you click the button "Review order" on the checkout page when you start with a "fresh" checkout? Or does it also happen in this case:
1. Go to checkout.
2. Don't fill in a required field.
3. Click "Review order" button.
4. Receive error message about the required field.
5. Fill in a required field.
6. Click "Review order" button.

If I have the 'Skip checkout review' checkbox checked at Checkout settings (checkbox rendered by Optional Checkout Review module) the "Review order" button will not appear, but instead the "Submit order" button will appear in that place (since the purpose of UC Optional Checkout Review module is to get the possibility to skip the "Review order" step.
So, the error seems to happen only when click "Submit order" button at 'cart/checkout' page (when 'Skip checkout review' checkbox is enabled/checked as mentioned above). Error doesn't happen in the other cases you mention above.

Don't know if it has importance but I also have these UC contributed modules installed:
Ajax Attribute Calculations 6.x-2.x-dev
Ajax Driven Cart 6.x-2.1
Delivery Time slot 6.x-1.0-beta4
Donation Incentives 6.x-1.1
Pictured cart block 6.x-1.0-beta3
Terms and conditions 6.x-1.0
Ubercart Profile Integration 6.x-2.x-dev
Ubercart Rule Integration 6.x-1.0-rc1
Ubercart Webform Checkout Pane 6.x-3.8

megachriz’s picture

Project: Ubercart Addresses » Extra Fields Checkout Pane
Version: 6.x-2.x-dev » 6.x-2.0-beta2
Component: Checkout » Code
Assigned: Unassigned » megachriz
Status: Postponed (maintainer needs more info) » Fixed

Good news! I have been able to reproduce the problem and I have tracked down the bug.

It was a bug in Extra Fields Pane which had something to do with caching. When a value was saved for an extra field, the cached value lacked information about the fields machine name (db_name). The caching lasts one request only, so this wasn't a problem with the order review step in it, because a redirect take place, which forced a reload from the database. However, with the Optional Checkout Review module, the loading of the field's value happened right after it's saving, which resulted into loading the field's value from the cache, thus without the machine name.

This is now fixed for both Extra Fields Pane 6.x-2.x as 7.x-1.x by checking if the field value's machine name is empty when code asks for it. If it is empty, the machine name will be loaded from the field instead.

Commits:
6.x-2.x commit
7.x-1.x commit

Thanks for reporting and giving valuable information for tracking down this bug!

miccelito’s picture

@MegaChriz

Mega great ;) Thanks for solving the issue so quickly. And I can confirm that it works now

miccelito’s picture

Status: Fixed » Active

Sorry to reopen this issue..

But I've just seen that the Uncaught exception 'UcAddressesInvalidFieldException' error message also appear when trying to access Order history - view, edit etc. I didn't see this before so I'm not sure if it's because I've changed anything else since then. Would be great if you get the possibility to verify if you get Uncaught exception 'UcAddressesInvalidFieldException' error message when clicking view, edit etc at Order history.

megachriz’s picture

Status: Active » Postponed (maintainer needs more info)

Are you using the latest 6.x-2.x-dev version now? The fix is not in the "stable" 6.x-2.0-beta2 release.

Does the error occur on all orders or only some of them? If some of them, what have these orders in common? For example, are they all after/before a specific date, do they have the same status, etc.?

miccelito’s picture

I'm using 6.x-2.0-beta2, as well I added the new lines according to your commit to class/UCXF_Value.class.php.
Error occuring on all orders at the moment.

megachriz’s picture

It probably will give the same result, but can you try again with the latest dev? I had one issue lately that took a long time to debug, and in the end it appeared a patch or a manual code change didn't completely made it.
There are no database updates in the latest dev.

miccelito’s picture

I'll try to update from 6.x-2.0-beta2 to latest dev. Will give you answer in a moment..

Edit: I've tested with latest dev now, the error is still there.

miccelito’s picture

Mentioned I've tested with latest dev til now, but the error is still there. I've no clue what could possibly cause the error..

megachriz’s picture

Ok, I don't know what's the cause of the error at the moment. Can give me the complete error message, just like you did at the beginning of this issue? The stack trace can be really helpful to know where to start looking.

Other question: did viewing orders worked earlier with Extra Fields Pane 6.x-2.x and Ubercart Addresses 6.x-2.x installed, say between June 25 and now? If so, did you installed any other modules lately?

miccelito’s picture

I guess viewing orders worked earlier with Extra Fields Pane installed, since I didn't notice this error until now.. I'll take a look what new modules have been installed lately..

Fatal error: Uncaught exception 'UcAddressesInvalidFieldException' with message 'Invalid field name title' in /*/sites/all/modules/uc_addresses/class/UcAddressesSchemaAddress.class.php:244 Stack trace: #0 /*/sites/all/modules/uc_addresses/class/UcAddressesSchemaAddress.class.php(187): UcAddressesSchemaAddress::fieldMustExist('title') #1 /*/sites/all/modules/uc_addresses/class/UcAddressesAddress.class.php(263): UcAddressesSchemaAddress->setField('title', '') #2 /*/sites/all/modules/uc_addresses/uc_addresses.module(661): UcAddressesAddress->setField('title', '') #3 /*/sites/all/modules/ubercart/uc_order/uc_order.module(1474): uc_addresses_order('load', Object(stdClass), NULL) #4 /*/sites/all/modules/ubercart/uc_order/uc_order.module(1199): uc_order_module_invoke('load', Object(stdClass in /*/sites/all/modules/uc_addresses/class/UcAddressesSchemaAddress.class.php on line 244

megachriz’s picture

Status: Postponed (maintainer needs more info) » Needs work

Thanks for reporting back. I've been able to reproduce the bug! The bug occurs when enabling and disabling the Ubercart Addresses Example module.
This time I think it's a bug in Ubercart Addresses, but I need to take a closer look at it before I can work on a fix. A possible workaround for this issue is by uninstalling the Ubercart Addresses Example module.

Changing status to "needs work" for me.

miccelito’s picture

Some week ago I was enabling and few minutes after disabling the Ubercart Addresses Example submodule, as you say.
And I did now uninstall the Ubercart Addresses Example module, which solved the problem.

megachriz’s picture

Status: Needs work » Fixed

The second bug is different from the first bug you reported (although they looked similar). As the first bug had been in Extra Fields Pane and the second bug is in Ubercart Addresses, I have opened a new issue in the Ubercart Addresses issue queue. Please continue there: #1678406: UcAddressesInvalidFieldException on order pages when enabling and disabling Ubercart Addresses Example module.

I'm setting this back to fixed.

Thanks for reporting!

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

edit