Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This seems not to work as expected on a fresh install (from ec_product.install):
$ptype = ec_product_ptypes_get('type', 'tangible');
ec_product_feature_enable($ptype, 'shippable');
Comment | File | Size | Author |
---|---|---|---|
#3 | ecommerce-ec_product_install-616830.patch | 869 bytes | Soren Jones |
Comments
Comment #1
Soren Jones CreditAttribution: Soren Jones commentedThe issue seems to be with calling drupal_write_record from hook_enable (via ec_product_feature_save and ec_product_feature_enable). http://api.drupal.org/api/function/drupal_write_record/6#comment-2273
I've found two solutions that work.
1) Substitute db_query for lines 105 and 106 in ec_product_enable.
2) Add drupal_get_schema to ec_product_enable before line 105 (or somewhere in ec_product_feature_enable).
I don't know which is better (e.g., Is it risky to call drupal_get_schema from ec_product_enable if people are enabling multiple modules?).
Or if there is another "best" option.
Any thoughts?
Comment #2
Xen CreditAttribution: Xen commentedI'd go with db_query. It's the safe option.
Comment #3
Soren Jones CreditAttribution: Soren Jones commentedXen, Thank you. Attached for review.
Comment #4
Xen CreditAttribution: Xen commentedLooks good to me, but it's Gordon that got the final say.
Comment #5
gordon CreditAttribution: gordon commentedI really don't like this esp. since if changes are made to ec_product_feature_enable() it is likely to break the initial install.
How because of your explanation I agree that inserting this directly is the safest option.
Just so this doesn't explanation doesn't get lost can you please add this a reference to this issue and the explantion to the in line documentation for ec_product_feature_enable() so if anything additional processing is added in future people should see it and replicate the code.
Also what would be even better is to add an assertion to one of the products tests to make sure that the tangible product has the shippable feature attached.
Thanks.
Powered by Dreditor.
Comment #6
Soren Jones CreditAttribution: Soren Jones commentedSo would it be best to get rid of ec_product_feature_enable() all together (remove it from ec_product) and use the direct insert in ec_product_update_5402() as well?
Will do on the reference and will take a shot at adding an assertion to one of product test.
Thanks for the feedback.