This a subissue of #1831424: Turn Ubercart Addresses address into an entity.


The Entity API module provides a hook called hook_entity_property_info() with which metadata about entity properties can be defined. Ubercart Addresses provides the hook hook_uc_addresses_fields() with which address fields can be registered. As each address field of an address is essentially a property of the upcoming address entity, it would be nice if property metadata can be defined in hook_uc_addresses_fields(), so modules that register address fields don't need to implement hook_entity_property_info() as well to define additional or similar information about their fields.

One metadata item is the data type of the field, simply called 'type'. This can be 'text', 'integer', 'boolean', etc. So, in preparation of the entity integration, it would be nice if the data type is declared for each field, which will fallback to 'text' for if it's not defined.

Affected versions

Though it would only have a function for the 7.x-1.x version, fields specifying their data types will also be implemented for the 6.x-2.x version for consistency (and the information *could* be useful for modules extending Ubercart Addresses as well).


The Ubercart Addresses Example module already used the 'type' property to define the database data type. The example module should be adjusted to remain compatible with future changes (Entity API integration).

Proposed resolution

Current registered address fields will get an extra property called 'type'. This will be mapped to Entity API property info later on. Optionally, other properties could be defined as documented by hook_entity_property_info().

Remaining tasks

User interface changes


API changes

Modules registering address fields should from now on define the data type of their fields if it's not supposed to be just text. Optionally, they can define other properties as documented by hook_entity_property_info().

I'm working on it.

#7 uc_addresses6-field-data-types-1910626-7.patch7.02 KBMegaChriz
PASSED: [[SimpleTest]]: [MySQL] 2,331 pass(es). View
#5 uc_addresses-field-data-types-1910626-5.patch10.78 KBMegaChriz
PASSED: [[SimpleTest]]: [MySQL] 3,144 pass(es). View
#3 uc_addresses-field-data-types-1910626-3.patch9.75 KBMegaChriz
FAILED: [[SimpleTest]]: [MySQL] 2,809 pass(es), 0 fail(s), and 1 exception(s). View
#1 uc_addresses-field-data-types-1910626-1.patch4.95 KBMegaChriz
PASSED: [[SimpleTest]]: [MySQL] 2,682 pass(es). View
Members fund testing for the Drupal project. Drupal Association Learn more


MegaChriz’s picture

Status: Active » Needs review
4.95 KB
PASSED: [[SimpleTest]]: [MySQL] 2,682 pass(es). View

First patch. This patch defines data types for each registered address field, plus it adjusts and cleans up uc_addresses_get_address_fields(). The example module is not adjusted yet. And it should be documented that data received with hook_uc_addresses_fields() will be passed to hook_entity_property_info().

MegaChriz’s picture

I've opened a separate issue for the problems in the example module: #1911136: Ubercart Addresses Example module: separate schema definitions from field handler API definitions. as these problems have less to do with the task itself.

MegaChriz’s picture

9.75 KB
FAILED: [[SimpleTest]]: [MySQL] 2,809 pass(es), 0 fail(s), and 1 exception(s). View

New patch. This patch adds some extra documentation and also sets a default for the "label" property for each field. The label is used by Entity API and visible in Rules (for example).

I think this one is good to go.

Status: Needs review » Needs work

The last submitted patch, uc_addresses-field-data-types-1910626-3.patch, failed testing.

MegaChriz’s picture

Status: Needs work » Needs review
10.78 KB
PASSED: [[SimpleTest]]: [MySQL] 3,144 pass(es). View

In addition of the patch in #3, this patch makes a change in the entity tests. These tests still expected a property called 'uid' of type 'integer', while the property was replaced by a property called 'user'. On it is advised to not use 'uid' as property, but use 'user' instead.

MegaChriz’s picture

Version: 7.x-1.x-dev » 6.x-2.x-dev
Status: Needs review » Patch (to be ported)

Committed #5.

Needs backport to 6.x-2.x.

MegaChriz’s picture

Status: Patch (to be ported) » Needs review
7.02 KB
PASSED: [[SimpleTest]]: [MySQL] 2,331 pass(es). View

Backport of the patch posted in #5. Note that Entity API related code is not included, because there is no Entity API for Drupal 6. The properties 'label' and 'options list' in field definitions are not backported, because these are only relevant to Entity API. The 'type' property could be useful in future enhancements.

MegaChriz’s picture

Version: 6.x-2.x-dev » 7.x-1.x-dev
Status: Needs review » Fixed

Committed #7.

Setting issue back to the version it was originally reported for and mark it as fixed.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Marked adjustment for example module as done.