Problem/Motivation
Generally there's a 32 char limit to entity type names (machine names).
Unfortunately commerce_coupon_usage_transaction
is 33 chars long. Which makes it basically incompatible with the core limitations. And as contrib modules often respect this limitations the same applies for contrib.
In my current case it is Entity Modified that complains.
Proposed resolution
As this is a limitation imposed by core we should fix it here and not e.g. in Entity Modified.
So way to go is rename commerce_coupon_usage_transaction
to e.g. commerce_coupon_usage_trans
.
I suggest to rename everything and not just the name of the entity type to keep consistency.
I hope this is possible - as 2.x still is in beta.
Attached patch has all the occurrences renamed and provides a update hook that renames the db table if necessary.
Remaining tasks
Reviews needed.
User interface changes
API changes
Entity type related things will break!
Customized views may break!
Comment | File | Size | Author |
---|---|---|---|
#11 | commerce_coupon-entity_type-too-long-2440857-11.patch | 11.54 KB | johnle |
|
Comments
Comment #2
das-peter CreditAttribution: das-peter commentedRe-rolled, hope this one applies.
Comment #4
das-peter CreditAttribution: das-peter commentedRe-rolled
Comment #5
torgosPizzaIs there a way someone like me can test this patch's effectiveness? We are having some odd bugs with Coupons but I won't know if this patch fixes them - can you tell me more about what kinds of issues might result with an entity machine name that's too long?
Comment #6
torgosPizzaI'm testing this on production and the patch applied cleanly, however I did get these errors when running drush updb:
array_keys() expects parameter 1 to be array, null given in common.inc:7154
Invalid argument supplied for foreach() entity.info.inc:151
These appear to have to do with a schema relationship but, as far as I can tell, everything seems to work fine despite the errors.
Comment #7
das-peter CreditAttribution: das-peter commentedWell e.g. Entity Modified has an own table in which it stores the modification time of entities - to do so it needs to match entity_type, entity_id, entity_revision and the timestamp.
The table uses a 32 char field for entity_type - as entity type should be 32 char - now if you try to store something longer than 32 chars this will lead to a DB error.
Did you have custom views? Any leftovers of
commerce_coupon_usage_transaction
in your code / config?Comment #8
torgosPizzaI never saw the errors mentioned as the reason for the patch but we've been using it in production with no issues. Suggest committing it.
Comment #9
torgosPizzaLooks like this patch no longer applies to the latest dev, as the usage.views.inc stuff fails and the rest needs an offset.
Also I wonder if instead of commerce_coupon_usage_trans we name it commerce_coupon_usage_txn which makes more sense to me.
Comment #10
kevster CreditAttribution: kevster commentedI tried applying this to 7.x-2.0-rc2 and although it ran the update I had other errors - a bunch of these:
Invalid argument supplied for foreach() common.inc:7176 [warning]
array_keys() expects parameter 1 to be array, null given [warning]
common.inc:7196
Also didnt fix issue and caused other errors re the table name change so I rolled back and applied this patch to entity_modified https://www.drupal.org/node/2538760.
Im not sure why this error popped up - only change I can think of was a new discount was added which because the compatibility with other discounts option for this discount not compat with doesnt work I have to choose "This discount is compatible with any discount except the selected discounts." and then add all others - maybe this data was too long for saving?
My client lost 14 orders over the weekend due to this bug popping up and orders with discounts not being able to be processed...
Latest dev may be ok without the entity_modified patch but beware using this patch on RC2 as it didnt work for me...
Comment #11
johnle CreditAttribution: johnle as a volunteer commentedUpdated the patch for step #4 to the current dev release. I've been running into the same issues using the entity_admin module. Tested out the patch and it seem to be working without any issues using a coupon in the checkout process now.
Comment #12
bfodeke CreditAttribution: bfodeke at Mediacurrent commentedComment #13
jcisio CreditAttribution: jcisio as a volunteer commentedThey are fixing it in entity_modified #2538760: Increase entity_type column to 64.