I have several discounts and I want to transfer them using a feature. I created feature with discounts and add it to a profile info file. When installing site I have error "EntityMetadataWrapperException: Unknown data property commerce_discount_offer. This is because the creation of field occurs in the function commerce_discount_install_helper which is called by later than the enable feature.

Comments

gaydamaka created an issue. See original summary.

gaydamaka’s picture

Assigned: Unassigned » gaydamaka
joelpittet’s picture

Status: Active » Needs review

We have tests now, changing to Needs Review to get testbots opinion on the patch.

joelpittet’s picture

Status: Needs review » Needs work
+++ b/commerce_discount.install
@@ -126,19 +133,17 @@ function commerce_discount_requirements($phase) {
+  field_info_cache_clear();
...
-    field_info_cache_clear();
+  if (!isset($field_types['entityreference'], $field_types['inline_conditions'], $field_types['commerce_product_reference'])) {

This was a performance improvement for clearing cache because install_helper is called when clearing cache too.

joelpittet’s picture

Not against this patch, it's has some promise! thanks for posting @gaydamaka

gaydamaka’s picture

gaydamaka’s picture

Status: Needs work » Needs review
br0ken’s picture

Status: Needs review » Reviewed & tested by the community

Used it on my a project - works really good! Let's have it merged.

joelpittet’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)
  1. +++ b/commerce_discount.install
    @@ -6,6 +6,14 @@
    +function commerce_discount_install() {
    +  field_info_cache_clear();
    +  commerce_discount_install_helper();
    +}
    

    All good with committing this without the field_info_cache_clear() call.

  2. +++ b/commerce_discount.install
    @@ -129,15 +137,6 @@ function commerce_discount_install_helper() {
    -  if (!isset($field_types['entityreference'])
    -    || !isset($field_types['inline_conditions'])
    -    || !isset($field_types['commerce_product_reference'])
    -  ) {
    -    field_info_cache_clear();
    -  }
    

    Question: Is there something wrong with this logic for it to be removed? Again this also is called on cache flushes so it likely needs to stay.

gaydamaka’s picture

gaydamaka’s picture

Status: Postponed (maintainer needs more info) » Needs review
br0ken’s picture

Status: Needs review » Reviewed & tested by the community

Want to see it merged.

joelpittet’s picture

Assigned: gaydamaka » Unassigned

Would have been nice if you two addressed my questions in #9 instead of throwing patches and RTBCing them. If just to instill a bit more confidence behind the patch.

Though I've thoroughly reviewed all the code paths in the changes and there should be no unforeseen problems with the latest.

Was a bit hesitant on the multiple isset() call change there at first too, because it's uncommon in core and could be seen as hard to read unless you know that isset() with multiple arguments returns FALSE on the first FALSE value and is short circuited the same as the || operator would.

Committed and pushed to latest dev branch.

joelpittet’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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