Closed (fixed)
Project:
Block Class
Version:
6.x-1.x-dev
Component:
User interface
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 Oct 2009 at 22:33 UTC
Updated:
8 Mar 2012 at 20:20 UTC
Jump to comment: Most recent file
Comments
Comment #1
BarisW commentedI'd be a bit more direct to change this to a bug. The strings are cut off because the database field only has 50 characters.
There is no check on the form however to warn the user that his string is too long. Or not even een MAXLENGTH on the form.
I'd say:Maxlength on the form (255) and change the databasefield to 255 chars.
Comment #2
todd nienkerk commentedWe should increase all three columns to 255 and set the classes input field to maxlength.
* Change block_class_schema()
* Add block_class_update_6001() to change existing schema
* Change block_class_form_alter() to increase input field to maxlength
Comment #3
dboulet commentedComment #4
mstrelan commentedThis is great, please commit ASAP!
Comment #5
BarisW commented+1
Comment #6
todd nienkerk commentedI've committed this patch to 6.x-1.x-dev. Please test. :)
Comment #7
todd nienkerk commentedThis will also need to be ported to the 7.x-1.x branch to allow easy Drupal 6.x->7.x upgrading. I've created an issue here:
#1020790: Port schema update to 7.x-1.x branch
Comment #8
sgabe commentedActually this change causes an error because a well known MySQL bug:
The problem is that 3 bytes are reserved for every character in UTF-8 tables and the compound key blows the maximum size of 1000 bytes set for keys.
Although it's possible to use class names with 255 chars but IMO it's unlikely and pointless. Furthermore we should adhere to the core Block module's database scheme and set the length 64 for the module field and 32 for delta.
Comment #9
BarisW commentedThe patch misses the maxlength on the fields. But I agree with your point that 64 should be enough, as long as the interface reflects this.
Comment #10
dboulet commentedAllowing 255 chars for the class name is not pointless. It's maybe a little excessive, but the 50 char limit is much too small, and I found myself reaching it multiple times which is very frustrating. Of course no one is going to create one class name that long, but you run into problems when wanting to add 6 or 7 or even 8 class names to one block.
sgabe, as you obviously have more MySQL expertise than myself, can you explain how changing the char length of the css_class column fixes your bug? From what I can tell, the key is built using the module and delta columns only.
Comment #11
sgabe commented@dboulet: what fixes the bug is changing (reducing) the length of the module and delta fields. About the class length, that was just a comment. Let's continue in #1020846: 7.x-1.x fails to install database schema ("Specified key was too long"), however I don't understand why did you change the length for these fields when this issue was supposed to be about only the class field.
Comment #12
dboulet commentedThanks for the explanation sgabe. To answer your question, I had only included those changes in the patch because of the comments in #2 from the project maintainer. Turns out it was a bad idea. :s
Thanks for bringing it to our attention.
Comment #13
dboulet commentedI'm going to mark this as fixed—any bugs related to this issue can be dealt with in other issues.
Comment #15
yang_yi_cn commentedThis is not fixed at all. I'll roll a patch soon.
Comment #16
yang_yi_cn commentedThe patch at #3 had 2 problems (I mention that because it has been committed and is in the dev branch right now):
First, there's a typo in the db_change_field() for the css_class field, it sets "size" instead of "length". As "size" is not a valid keyword, it will cause update error like this:
Failed: ALTER TABLE {block_class} CHANGE `css_class` `css_class` NOT NULLSecond, if the module and delta were changed to 255 it will break primary key as #8 mentioned.
To me, I do need the css_class char limit increase to 255, not because I'm going to use a crazy long class name, but because I want to give multiple class to the block, which can be done by having them space separated. And when you have multiple classes, it's very easy to exceed 50 chars.
So, my patch, which is against current dev version, will update the css_class correctly to 255 and keep module at 64, delta at 32.
I've tested it on my project and it actually works. Please review and commit it if possible.
Comment #17
yang_yi_cn commentedComment #18
dboulet commentedThe patch in #16 changes the update function, but not the schema information. Perhaps the code from this patch should instead be added to this issue: #1020846: 7.x-1.x fails to install database schema ("Specified key was too long").
Comment #19
yang_yi_cn commentedright, let's mark this a dup of #1020846: 7.x-1.x fails to install database schema ("Specified key was too long") and I'll roll a new patch there.
Comment #20
dboulet commentedif you don't mind, I'm marking this as "fixed" once again—technically the original issue has been fixed.
Comment #21
aasarava commentedDboulet, this is not "fixed". That would happen if the patch in #16 were applied to 6.x-dev. As it is now, the dev branch is still improperly changing the size of the key in addition to changing the size of the css_class field.
Comment #22
berenddeboer commentedProper install patch committed.
Comment #23
sgabe commentedThank you berenddeboer! It is so good to finaly see this in the repository.