In uc_order_entity_info:

    'entity keys' => array(
        'id' => 'order_id',
        'label' => t('Order'),
      ),

But documentation states that "label" inside the entity keys definition should be:

label: The name of the property that contains the entity label. For example, if the entity's label is located in $entity->subject, then 'subject' should be specified here. If complex logic is required to build the label, a 'label callback' should be defined instead (see the 'label callback' section above for details).

This makes any code that relies on "label" being a real property completely broken. Such as the entity reference module, or even parts of Core.

I've fixed this on a hook, just wanted to report here that t('Order') should be either:

* Completely removed
* Replaced by a property of the order (such as order_id)
* Removed + Add a "label callback"

CommentFileSizeAuthor
#2 2788513-2.patch666 bytesTR
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

david_garcia created an issue. See original summary.

TR’s picture

Priority: Critical » Normal
Status: Active » Needs review
FileSize
666 bytes

That line of code was added more than 6 years ago, when Drupal 7 was still in alpha. I suspect it was correct back then and that the Entity API changed underneath us without our noticing. You're the first person in all that time to encounter a problem with this!

In D8 this is done correctly - it's only an issue in the old D7 code. It seems this is a problem with both the order entity and the order product entity. For both of these, in D8, we don't use the label in the keys, so I vote for just removing this in D7 as well.

david_garcia’s picture

Status: Needs review » Reviewed & tested by the community

Straightforward. Thanks!

yuraosn’s picture

Thanks!

  • TR committed aae1683 on 7.x-3.x
    Issue #2788513 by david_garcia, TR: uc_order entity keys are WRONG
    
TR’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thanks. And thanks for your patience.

Status: Fixed » Closed (fixed)

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