The latest changes to rules database schema breaks commerce module install and possibly other modules too:
In this example, the rule failing to install is 'commerce_checkout_order_status_update', which is 37 characters long, but 'name' is suddenly only 32 characters wide. It seems unreasonable to change the rules on how long a rule name can be at this point of the game.
WD rules_config: PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'name' at row 1: INSERT INTO {rules_config} (name, label, plugin, active, weight, status, module, data) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => commerce_checkout_order_status_update [:db_insert_placeholder_1] => Update the order status on checkout completion [:db_insert_placeholder_2] => reaction rule [:db_insert_placeholder_3] => 1 [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => 2 [:db_insert_placeholder_6] => commerce_checkout [:db_insert_placeholder_7] => O:17:"RulesReactionRule":13:{s:9:"*parent";N;s:2:"id";N;s:12:"*elementId";N;s:6:"weight";i:0;s:8:"settings";a:0:{}s:4:"name";s:37:"commerce_checkout_order_status_update";s:6:"module";s:17:"commerce_checkout";s:6:"status";i:2;s:5:"label";s:46:"Update the order status on checkout completion";s:11:"*children";a:1:{i:0;O:11:"RulesAction":6:{s:9:"*parent";r:1;s:2:"id";N;s:12:"*elementId";N;s:6:"weight";i:0;s:8:"settings";a:3:{s:21:"commerce_order:select";s:14:"commerce-order";s:11:"order_state";s:7:"pending";s:18:"#_needs_processing";b:1;}s:14:"*elementName";s:27:"commerce_order_update_state";}}s:7:"*info";a:0:{}s:13:"*conditions";O:8:"RulesAnd":8:{s:9:"*parent";r:1;s:2:"id";N;s:12:"*elementId";N;s:6:"weight";i:0;s:8:"settings";a:0:{}s:11:"*children";a:0:{}s:7:"*info";a:0:{}s:9:"*negate";b:0;}s:9:"*events";a:1:{i:0;s:26:"commerce_checkout_complete";}} ) in drupal_write_record() (line 6859 of /var/aegir/platforms/xxx/includes/common.inc).
Comment | File | Size | Author |
---|---|---|---|
#14 | rules_config_name.patch | 3.2 KB | fago |
#12 | rules_config_name.patch | 3.31 KB | fago |
#5 | schema-fix-1227018-p0.patch | 367 bytes | EclipseGc |
#4 | schema-fix-1227018.patch | 375 bytes | EclipseGc |
Comments
Comment #1
EclipseGc CreditAttribution: EclipseGc commentedJust lost 6 hours trying to track this in an install profile :-S
Comment #2
Dave Reidhttp://drupalcode.org/project/rules.git/commitdiff/db1c6758eb0f31ab0de7f...
When you shorten column lengths in hook_schema()s, you have to also add hook_update_N()s with db_change_field() with the new spec.
Comment #3
EclipseGc CreditAttribution: EclipseGc commentedQuick patch to 128.
Comment #4
EclipseGc CreditAttribution: EclipseGc commentedoops, failed to actually grab the patch
Comment #5
EclipseGc CreditAttribution: EclipseGc commentedAdding a p0 patch for drush make.
Comment #6
rfayThis is a fundamental #fail: Can't install at all.
Comment #7
rfay@EclipseGC, Drush Make now supports normal patches. Fix went in 10 days ago or so (finally).
Comment #7.0
rfayAdded more analysis of the error message.
Comment #8
rfayUpdated issue summary with more detail.
We probably need to just go back to 255 characters, unless there's some reason not to.
If this is going to be shortened, it needs to have a db_change_field() and also the index has to be removed and rebuilt in hook_update_N().
Comment #9
fagoouch, sry for creating those troubles.
The UI has already #maxlength == 32 so I thought this is a safe change. Obviously it isn't... :(
I see that programmatically created rules don't have to follow that though, in particular as we don't support name changes there anyway. Anyway, we should sync both values.
Problem is, we also need an index in the mysql rules_scheduler table, but mysql is by default limited to 1000byte indexes and it looks like db-tng doesn't support changing that. With utf8, we have varcharsize*3 for the index, what means with the index (machine_name, identifier) we cannot have 255*3+255*3 (>1000).
I think it doesn't make much sense to have that long machine-names, as it just makes identifying slower/harder. 32 should be basically enough, but I see might be a bit less in certain operations. So what about 64?
64*3+255*3 would work.
What's the longest machine-readable name in drupal commerce? Any reason to have such long names there?
>If this is going to be shortened, it needs to have a db_change_field() and also the index has to be removed and rebuilt in hook_update_N().
That's painful for such a "small change", but yes we need to that.
Comment #10
rfayThanks, fago. I suspect 64 would be OK. (Note that feeds had the key length problem recently as well, #1044882: table feeds_item could not be created pdo exception key was too long)
In the below, it looks to me like the second one was probably created with the UI.
select name, length(name) as fieldlength from rules_config order by fieldlength desc limit 10
Comment #11
EclipseGc CreditAttribution: EclipseGc commentedYeah, I think the tendency has been toward longer names since, at least as I understand it, Drupal Commerce did not want to repeat the ubercart methodology and prefix every thing as dc/uc, and instead opted for "commerce_". It would be good if we didn't have to break that methodology for rules, and I THINK we can live in 64 (I just changed things back to 255 via the above patch any time we're working with dev, so I've not actually tested it).
commerce_checkout_order_status_update is the specific ruleset that kills most installs, but we only know that because we hacked at our dependencies until we figured it out. Hopefully we can live in 64 as well. It'd be good to hear from Ryan on this, but I think he's still on vacation.
Eclipse
Comment #12
fagook, so here is patch fixing it to 64. Please test!
>In the below, it looks to me like the second one was probably created with the UI.
hm, I guess that might have been caused by bug that was in the machine-name generation of core. It didn't respect the max-length value, so longer values might have been auto-generated due to that. The core bug has been already fixed though, so it should not happen any more.
Comment #13
recidive CreditAttribution: recidive commentedCommerce module install works again after applying the patch.
After running the update, the rules_config table is changed fine:
I don't have rules_scheduler enabled to test the upgrade, but looking at the patch I see rules_scheduler_update_7202() update the rules_config table again, when it should update the rules_scheduler table?
Comment #14
fagothanks.
ok, I've fixed that and tested it on another site. However, the rules-scheduler update failed to create the new keys via db_change_field() - I don't know why as it works for the rules update. Reverting to a db_add_unique_key() worked for me.
So this could need another tester who makes sure the upgrade works and all indexes have been properly created.
Comment #15
ezra-g CreditAttribution: ezra-g commentedI applied #14 and the database update ran successfully.
Comment #16
recidive CreditAttribution: recidive commentedI tested upgrading rules schedule module, bellow is the rules_scheduler table structure before and after running the schema update:
Before:
After:
Comment #17
fagothanks, committed.
Comment #18.0
(not verified) CreditAttribution: commentedMore detail on #fail analysis
Comment #19
dobe CreditAttribution: dobe commentedI have a problem... 64 characters is too small for my name fields for Commerce Pickup module my rule name ends up looking like this: commerce_shipping_service_commerce_pickup__commerce_customer_profile__23197
I did a custom patch for my situation, is it really necessary to limit this field so much?