Project:Ubercart Addresses
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:freixas
Status:closed (fixed)

Issue Summary

Hi. Adding or entering addresses gives the error in the issue title and fails terminally with Ubercart 2.0 RC3.

Looking at the Drupal database, it seems that all the address fields have newly been suffixed with "delivery_", such that the correct column should now be "delivery_first_name?"

Comments

#1

Okay, having now taken a more detailed look at the code of this module, it looks like uc_addresses is actually supposed to have columns/fields like "first_name," etc. due to different address types like delivery and billing.

So how my Drupal database's uc_addresses ended up with "delivery_" suffixes I dunno, though I did do a straight upgrade from d5uc1 to d6uc2 which seemed to work 99% okay.

So I edited the structure of uc_addresses in my Drupal database (with phpMyAdmin) accordingly to mirror that of my old d5 database (field name and type particularly), and everything now seems to be working okay.

I think this issue should remain open to see if anyone else would have the same issue. I updated my Drupal database twice from d5 to d6 with same results.

#2

same problem. i had to remove the "delivery_" prefix in the uc_addresses table. not sure if that was the right thing to do but it works without errors now.

#3

Looks like the field names were changed as part of the First Drupal 6 Update uc_address.install line 176

/**
* First Drupal 6 update: standardize database definitions as per uc_orders
*/
function uc_addresses_update_6000() {
  db_drop_primary_key($ret, 'uc_addresses');
  db_drop_index($ret, 'uc_addresses', 'aid_uid_idx');
  db_change_field($ret, 'uc_addresses', 'aid', 'aid', array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), array('primary key' => array('aid')));
  db_change_field($ret, 'uc_addresses', 'uid', 'uid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
  db_change_field($ret, 'uc_addresses', 'first_name', 'delivery_first_name', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
  db_change_field($ret, 'uc_addresses', 'last_name', 'delivery_last_name', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
  db_change_field($ret, 'uc_addresses', 'phone', 'delivery_phone', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
  db_change_field($ret, 'uc_addresses', 'company', 'delivery_company', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
  db_change_field($ret, 'uc_addresses', 'street1', 'delivery_street1', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
  db_change_field($ret, 'uc_addresses', 'street2', 'delivery_street2', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
  db_change_field($ret, 'uc_addresses', 'city', 'delivery_city', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
  db_change_field($ret, 'uc_addresses', 'zone', 'delivery_zone', array('type' => 'int', 'unsigned' => TRUE, 'size' => 'medium', 'not null' => TRUE, 'default' => 0));
  db_change_field($ret, 'uc_addresses', 'postal_code', 'delivery_postal_code', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
  db_change_field($ret, 'uc_addresses', 'country', 'delivery_country', array('type' => 'int', 'unsigned' => TRUE, 'size' => 'medium', 'not null' => TRUE, 'default' => 0));
  db_add_index($ret, 'uc_addresses', 'aid_uid_idx', array('aid', 'uid'));

  db_drop_primary_key($ret, 'uc_addresses_defaults');
  db_change_field($ret, 'uc_addresses_defaults', 'aid', 'aid', array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE));
  db_change_field($ret, 'uc_addresses_defaults', 'uid', 'uid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
  db_add_primary_key($ret, 'uc_addresses_defaults', array('aid', 'uid'));

  return $ret;
}

The comment says this was done to standardize with uc_orders, so looks like the module source code should be updated to reflect the naming change as well.

#4

untested patch attached. Basically it changes the instances that interact with the database from first_name -> delivery_first_name, last_name -> delivery_last_name, etc.

Will try and run simpletest against the patch when I have time.

AttachmentSizeStatusTest resultOperations
uc_addressdelivery.patch3 KBIgnored: Check issue status.NoneNone

#5

The last patch did not fix the address select in /checkout because the apply_address function in uc_cart.js was looking for address.first_name and not address.delivery_first_name. To patches attached. One to update uc_addresses.js with a new apply_uc_address function (uc_addressdeliveryjs.patch), and the other (uc_addressdelivery.patch) to update uc_addresses.module to use the new function.

AttachmentSizeStatusTest resultOperations
uc_addressdelivery.patch4.09 KBIgnored: Check issue status.NoneNone
uc_addressdeliveryjs.patch1.62 KBIgnored: Check issue status.NoneNone

#6

Assigned to:Anonymous» freixas
Status:active» fixed

The submitted patches won't work. They will fix the problem for people who update from D5, but break the code for anyone installing uc_addresses on D6 for the first time.

The first sign that something is wrong is that addresses can represent both billing and delivery, so it makes no sense to prefix them with "delivery_".

The second sign that something is wrong is that I'm not getting a lot of complaints about this problem.

I looked into this and realized that the problem was caused by too much cut/paste for uc_orders when updating the module to D6. If you are installing uc_addresses for the first time, you will get the latest database as defined by the function uc_addresses_schema() in uc_addresses.install. This function creates a database without the "delivery_" prefixes and all works fine.

If you are updating an existing uc_addresses module to D6, you will get update 6000, which will add the delivery_ prefix. This problem was due to too much cut/paste from the uc_orders module.

I have added update 6001 to remove the delivery_ prefixes. The fix should appear in the next dev release dated 12/10/2009 or later.

#7

Status:fixed» closed (fixed)

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

nobody click here