I'm getting the following error when trying to enable the commerce_coupon 2.x-dev module after having disabled it. Here is the error:

EntityMetadataWrapperException: Unknown data property coupon_count. in EntityStructureWrapper->getPropertyInfo() (line 335 of /drupal/sites/all/modules/entity/includes/entity.wrapper.inc).

Once I uninstalled everything and then reinstalled it worked fine, but it was frustrating to have to uninstall as I had already entered a few coupons.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

deggertsen’s picture

Issue summary: View changes
andre4s_y’s picture

Assigned: Unassigned » andre4s_y
Status: Active » Needs review
FileSize
520 bytes

I am able to reproduce this bug.

Occured when admin try to enable the module.
This following functions get called:

  1. commerce_discount_default_rules_configuration(),
  2. commerce_coupon_commerce_discount_rule_build(), and
  3. commerce_coupon_cache_coupon_count() get called and stop at $discount_wrapper->coupon_count->value().

Now, what is coupon_count property?
A property at commerce_discount entity.

[coupon_count] => Array
  (
    [type] => integer
    [label] => Coupon count
    [getter callback] => commerce_coupon_get_discount_properties
  )

Which is declared using function commerce_coupon_entity_property_info_alter() at commerce_coupon.info.inc.

So, why it is not available when admin try to enable the module?
Because the entity property info cache get flushed upon module disable process.

Solution:
Implements hook_enable which perform clearing entity property info cache upon module enable proccess => in order to get cache refreshed and hook_entity_property_info_alter() called.

I have created a patch. Please help to review. :)
Thank you.

  • andre4s_y authored 7cffe61 on 7.x-2.x
    Issue #2316899 by andre4s_y: Errors when trying to enable after...
dpolant’s picture

Status: Needs review » Closed (fixed)

Thanks for the fix - I committed this patch.